OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
DODS_Date Class Reference

The DODS Date object. More...

#include <DODS_Date.h>

Collaboration diagram for DODS_Date:
Collaboration graph

Public Member Functions

int day () const
 ). More...
 
int day_number () const
 
 DODS_Date (int year, int month, int day)
 
 DODS_Date (int year, int month, int day, date_format format)
 
date_format format () const
 
double fraction () const
 
long julian_day () const
 
bool OK () const
 Class invariant. More...
 
time_t unix_time () const
 Return the number of seconds since 00:00:00 UTC 1 Jan 1970. More...
 
Constructors
 DODS_Date ()
 Create an empty date. More...
 
 DODS_Date (string date_str)
 Build a DODS_Date by parsing the string #date_str#. More...
 
 DODS_Date (BaseType *arg)
 Build a DODS_Date by parsing the DODS string contained in #arg#. More...
 
 DODS_Date (int year, int day_num)
 Build a DODS_Date using year and day-number values. More...
 
Assignment
void set (string date)
 Parse the string and assign the value to this object. More...
 
void set (BaseType *arg)
 Parse the DODS string and assign the value to this object. More...
 
void set (int year, int day_number)
 Assign the date using the two integers. More...
 
void set (int year, int month, int day)
 Assign the date using three integers. More...
 
void set (int year, int month, int day, date_format format)
 Assign the date using three integers and a date_format enumeration. More...
 
Access
string get (date_format format=ymd) const
 Get the string representation for this date. More...
 
int year () const
 
int month () const
 

Friends

Relational operators
int operator== (DODS_Date &d1, DODS_Date &d2)
 Equality. More...
 
int operator!= (DODS_Date &d1, DODS_Date &d2)
 Inequality. More...
 
int operator< (DODS_Date &d1, DODS_Date &d2)
 Less than. More...
 
int operator> (DODS_Date &d1, DODS_Date &d2)
 Greater than. More...
 
int operator<= (DODS_Date &d1, DODS_Date &d2)
 Less than or equal. More...
 
int operator>= (DODS_Date &d1, DODS_Date &d2)
 Greater than or equal. More...
 

Detailed Description

The DODS Date object.

This provides a way to translate between local representations of dates and the DODS standard representation(s). The DODS_Date object provides constructors, accessors and comparison operations; DODS servers which support the DODS standard representation of dates must implement CE functions that make use of this object.

Author
James Gallagher

Definition at line 108 of file DODS_Date.h.

Constructor & Destructor Documentation

DODS_Date::DODS_Date ( )

Create an empty date.

Set the date using one of the #set_date# mfuncs.

See also
set_date()

Definition at line 95 of file DODS_Date.cc.

DODS_Date::DODS_Date ( string  date_str)

Build a DODS_Date by parsing the string #date_str#.

If #date_str# is of the form `yyyy/ddd' assume that it is in year and day-number format. If it is of the form `yyyy/mm/dd' assume it is in year, month and day format. Note that if `yyyy' is `98' that means year 98 A.D., not 1998.

Parameters
date_strA string containing the date.
DODS_Date::DODS_Date ( BaseType *  arg)

Build a DODS_Date by parsing the DODS string contained in #arg#.

Throws Error if #arg# is not a DODS Str object.

Parameters
argA DODS string containing the date.
See also
DODS_Date(string).

Definition at line 100 of file DODS_Date.cc.

References set().

Here is the call graph for this function:

DODS_Date::DODS_Date ( int  year,
int  day_num 
)

Build a DODS_Date using year and day-number values.

This constructor assumes that the two integers are the year and day-number, respectively.

Parameters
yearThe year. `98' is 98 A.D., not 1998.
day_numThe day-number, 1 Jan is day 1.

Definition at line 111 of file DODS_Date.cc.

References set().

Here is the call graph for this function:

DODS_Date::DODS_Date ( int  year,
int  month,
int  day 
)

Definition at line 116 of file DODS_Date.cc.

References set().

Here is the call graph for this function:

DODS_Date::DODS_Date ( int  year,
int  month,
int  day,
date_format  format 
)

Definition at line 121 of file DODS_Date.cc.

References set().

Here is the call graph for this function:

Member Function Documentation

int DODS_Date::day ( ) const

).

Definition at line 402 of file DODS_Date.cc.

Referenced by DODS_Date_Time::day(), set(), and DODS_Date_Time::unix_time().

int DODS_Date::day_number ( ) const
Returns
The day-number of the year (1 == 1 Jan).

Definition at line 407 of file DODS_Date.cc.

Referenced by DODS_Date_Time::day_number().

date_format DODS_Date::format ( ) const
Returns
The format type.

Definition at line 419 of file DODS_Date.cc.

Referenced by operator<=(), operator==(), operator>=(), and set().

double DODS_Date::fraction ( ) const

Definition at line 424 of file DODS_Date.cc.

References days_in_year().

Referenced by DODS_Date_Time::get(), and get().

Here is the call graph for this function:

string DODS_Date::get ( date_format  format = ymd) const

Get the string representation for this date.

By default the y/m/d format is used. To get the year/year-day format use yd# for the value of format#.

Throws Error if format# is not ymd# or yd#.

Parameters
formatThe format of the date.
See also
date_format.
Returns
The date's string representation.

Definition at line 429 of file DODS_Date.cc.

References assert, decimal, fraction(), iso8601, yd, ym, and ymd.

Referenced by DODS_Date_Time::get().

Here is the call graph for this function:

long DODS_Date::julian_day ( ) const
Returns
The Julian day number for this date.

Definition at line 412 of file DODS_Date.cc.

Referenced by DODS_Date_Time::julian_day(), and set().

int DODS_Date::month ( ) const
Returns
The month of the year (1 == January, ..., 12 == December).

Definition at line 397 of file DODS_Date.cc.

Referenced by DODS_Date_Time::month(), operator<=(), operator==(), operator>=(), set(), and DODS_Date_Time::unix_time().

bool DODS_Date::OK ( ) const

Class invariant.

Returns
True for a valid instance, otherwise false.

Definition at line 88 of file DODS_Date.cc.

References unknown_format.

Referenced by set().

void DODS_Date::set ( string  date)

Parse the string and assign the value to this object.

See also
DODS_Date(string)

Referenced by DODS_Date(), DODS_Date_Time::set(), and set().

void DODS_Date::set ( BaseType *  arg)

Parse the DODS string and assign the value to this object.

See also
DODS_Date(BaseType *arg)

Definition at line 126 of file DODS_Date.cc.

References set().

Here is the call graph for this function:

void DODS_Date::set ( int  year,
int  day_number 
)

Assign the date using the two integers.

See also
DODS_Date(int year, int day_number)

Definition at line 312 of file DODS_Date.cc.

References assert, days_to_month_day(), julian_day(), OK(), yd, and year().

Here is the call graph for this function:

void DODS_Date::set ( int  year,
int  month,
int  day 
)

Assign the date using three integers.

See also
DODS_Date(int year, int month, int day)

Definition at line 324 of file DODS_Date.cc.

References assert, day(), julian_day(), month(), month_day_to_days(), OK(), year(), and ymd.

Here is the call graph for this function:

void DODS_Date::set ( int  year,
int  month,
int  day,
date_format  format 
)

Assign the date using three integers and a date_format enumeration.

See also
DODS_Date(int year, int month, int day, date_format format)

Definition at line 337 of file DODS_Date.cc.

References assert, day(), format(), julian_day(), month(), month_day_to_days(), OK(), and year().

Here is the call graph for this function:

time_t DODS_Date::unix_time ( ) const

Return the number of seconds since 00:00:00 UTC 1 Jan 1970.

If the date is before 1 Jan 1970, return DODS_UINT_MAX. If the date is too late to represent as seconds since 1 Jan 1970, return DODS_UINT_MAX. Each day starts at 00:00:00 UTC.

Returns
The date in seconds since 1 Jan 1970.
See also
dods-limits.h
time.h
mktime(3)

Definition at line 463 of file DODS_Date.cc.

int DODS_Date::year ( ) const
Returns
The year in years A.D.

Definition at line 392 of file DODS_Date.cc.

Referenced by DODS_Date_Time::get(), operator<=(), operator==(), operator>=(), set(), DODS_Date_Time::unix_time(), and DODS_Date_Time::year().

Friends And Related Function Documentation

int operator!= ( DODS_Date d1,
DODS_Date d2 
)
friend

Inequality.

Definition at line 360 of file DODS_Date.cc.

int operator< ( DODS_Date d1,
DODS_Date d2 
)
friend

Less than.

Definition at line 365 of file DODS_Date.cc.

int operator<= ( DODS_Date d1,
DODS_Date d2 
)
friend

Less than or equal.

Definition at line 375 of file DODS_Date.cc.

int operator== ( DODS_Date d1,
DODS_Date d2 
)
friend

Equality.

Definition at line 349 of file DODS_Date.cc.

int operator> ( DODS_Date d1,
DODS_Date d2 
)
friend

Greater than.

Definition at line 370 of file DODS_Date.cc.

int operator>= ( DODS_Date d1,
DODS_Date d2 
)
friend

Greater than or equal.

Definition at line 383 of file DODS_Date.cc.


The documentation for this class was generated from the following files: