bes  Updated for version 3.20.6
DODS_Date Class Reference

#include <DODS_Date.h>

Collaboration diagram for DODS_Date:
Collaboration graph

Public Member Functions

int day () const
 
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
 
time_t unix_time () const
 
Constructors
 DODS_Date ()
 
 DODS_Date (string date_str)
 
 DODS_Date (BaseType *arg)
 
 DODS_Date (int year, int day_num)
 
Assignment
void set (string date)
 
void set (BaseType *arg)
 
void set (int year, int day_number)
 
void set (int year, int month, int day)
 
void set (int year, int month, int day, date_format format)
 
Access
string get (date_format format=ymd) const
 
int year () const
 
int month () const
 

Relational operators

bool OK () const
 
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() [1/5]

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() [2/5]

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.

Definition at line 106 of file DODS_Date.cc.

◆ DODS_Date() [3/5]

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.

◆ DODS_Date() [4/5]

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.

◆ DODS_Date() [5/5]

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

Definition at line 116 of file DODS_Date.cc.

Member Function Documentation

◆ day()

int DODS_Date::day ( ) const

).

Definition at line 402 of file DODS_Date.cc.

◆ day_number()

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.

◆ format()

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

Definition at line 419 of file DODS_Date.cc.

◆ get()

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.

◆ julian_day()

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

Definition at line 412 of file DODS_Date.cc.

◆ month()

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

Definition at line 397 of file DODS_Date.cc.

◆ OK()

bool DODS_Date::OK ( ) const

Class invariant.

Returns
True for a valid instance, otherwise false.

Definition at line 88 of file DODS_Date.cc.

◆ set() [1/5]

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.

◆ set() [2/5]

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.

◆ set() [3/5]

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.

◆ set() [4/5]

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.

◆ set() [5/5]

void DODS_Date::set ( string  date)

Parse the string and assign the value to this object.

See also
DODS_Date(string)

Definition at line 290 of file DODS_Date.cc.

◆ unix_time()

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.

◆ year()

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

Definition at line 392 of file DODS_Date.cc.

Friends And Related Function Documentation

◆ operator!=

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

Inequality.

Definition at line 360 of file DODS_Date.cc.

◆ operator<

int operator< ( DODS_Date d1,
DODS_Date d2 
)
friend

Less than.

Definition at line 365 of file DODS_Date.cc.

◆ operator<=

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

Less than or equal.

Definition at line 375 of file DODS_Date.cc.

◆ operator==

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

Equality.

Definition at line 349 of file DODS_Date.cc.

◆ operator>

int operator> ( DODS_Date d1,
DODS_Date d2 
)
friend

Greater than.

Definition at line 370 of file DODS_Date.cc.

◆ operator>=

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: