In file DODS_Date.h:

class DODS_Date

The DODS Date object

Public Methods

bool OK() const
Class invariant

Public

Constructors
DODS_Date()
Create an empty date
DODS_Date(String date_str)
Build a DODS\_Date by parsing the string #date_str#
DODS_Date(BaseType *arg)
Build a DODS\_Date by parsing the DODS String contained in #arg#
DODS_Date(int year, int day_num)
Build a DODS\_Date using year and day-number values
DODS_Date(int year, int month, int day)
Build a DODS\_Date using year, month and day values
Assignment
void set(String date)
Parse the string and assign the value to this object
void set(BaseType *arg)
Parse the DODS String and assign the value to this object
void set(int year, int day_number)
Assign the date using the two integers
void set(int year, int month, int day)
Assign the date using three integers
Access
String get(date_format format = ymd) const
Get the string representation for this date
int year() const
int month() const
int day() const
int day_number() const
long julian_day() const
time_t unix_time() const
Return the number of seconds since 00:00:00 UTC 1 Jan 1970
Relational operators
friend int operator==(DODS_Date &d1, DODS_Date &d2)
Equality
friend int operator!=(DODS_Date &d1, DODS_Date &d2)
Inequality
friend int operator<(DODS_Date &d1, DODS_Date &d2)
Less than
friend int operator>(DODS_Date &d1, DODS_Date &d2)
Greater than
friend int operator<=(DODS_Date &d1, DODS_Date &d2)
Less than or equal
friend int operator>=(DODS_Date &d1, DODS_Date &d2)
Greater than or equal

Documentation

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.
Constructors

DODS_Date()
Create an empty date. Set the date using one of the #set_date# mfuncs.
See Also:
set_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_str - A string containing the 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:
arg - A DODS String containing the date.
See Also:
DODS_Date(String).

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:
year - The year. `98' is 98 A.D., not 1998.
day_num - The day-number, 1 Jan is day 1.

DODS_Date(int year, int month, int day)
Build a DODS\_Date using year, month and day values.
Parameters:
year - The year. As with the other constructors, does not prefix 1900 to two digit years.
month - The month of the year; 1 == January, ..., 12 == December.
day - The day of the month; 1, ..., \{31, 30, 29, 28\}.

Assignment

void set(String date)
Parse the string and assign the value to this object.
See Also:
DODS_Date(string)

void set(BaseType *arg)
Parse the DODS String and assign the value to this object.
See Also:
DODS_Date(BaseType *arg)

void set(int year, int day_number)
Assign the date using the two integers
See Also:
DODS_Date(int year, int day_number)

void set(int year, int month, int day)
Assign the date using three integers
See Also:
DODS_Date(int year, int month, int day)

Access

String 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#.
Returns:
The date's string representation.
Parameters:
format - The format of the date.
See Also:
date_format.

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

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

int day() const
Returns:
The day of the month (1, ... \{28, 29, 30, 31\}).

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

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

time_t 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)

Relational operators

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

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

friend int operator<(DODS_Date &d1, DODS_Date &d2)
Less than

friend int operator>(DODS_Date &d1, DODS_Date &d2)
Greater than

friend int operator<=(DODS_Date &d1, DODS_Date &d2)
Less than or equal

friend int operator>=(DODS_Date &d1, DODS_Date &d2)
Greater than or equal

bool OK() const
Class invariant.
Returns:
True for a valid instance, otherwise false.


This class has no child classes.
Author:
James Gallagher

alphabetic index hierarchy of classes


generated by doc++