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

The DODS Time object. More...

#include <DODS_Time.h>

Collaboration diagram for DODS_Time:
Collaboration graph

Public Member Functions

double get_epsilon () const
 Get the value of epsilon used for equality tests. More...
 
bool OK () const
 Class invariant. More...
 
void set_epsilon (double eps)
 Set the value of epsilon used for equality tests. More...
 
Constructors
 DODS_Time (string time)
 Build a DODS_Time by parsing the String #time#. More...
 
 DODS_Time (BaseType *arg)
 Build a DODS_Time by parsing the DODS Str #arg#. More...
 
 DODS_Time (dods_uint32 hh, dods_uint32 mm, bool gmt=false)
 Build a DODS_Time. More...
 
 DODS_Time (dods_uint32 hh, dods_uint32 mm, double ss, bool gmt=false)
 Build a DODS_Time. More...
 
 DODS_Time ()
 Build an empty DODS_Time. More...
 
Assignment
void set (string time)
 Set the value by parsing the string #time#. More...
 
void set (BaseType *arg)
 Set the value by parsing the DODS Str #arg#. More...
 
void set (int hh, int mm, bool gmt=false)
 Set the value using the given numeric values. More...
 
void set (int hh, int mm, double ss, bool gmt=false)
 Set the value using the given numeric values. More...
 
Access
string get (bool gmt=true) const
 Get the string representation of time. More...
 
int hours () const
 
int minutes () const
 
double seconds () const
 
bool gmt () const
 
double seconds_since_midnight () const
 Get the number of seconds since midnight. More...
 
double fraction () const
 Get the time as a fraction of a day. More...
 

Friends

Relational operators
int operator== (DODS_Time &t1, DODS_Time &t2)
 Equality. More...
 
int operator!= (DODS_Time &t1, DODS_Time &t2)
 Inequality. More...
 
int operator< (DODS_Time &t1, DODS_Time &t2)
 Less-than. More...
 
int operator> (DODS_Time &t1, DODS_Time &t2)
 Greater-than. More...
 
int operator<= (DODS_Time &t1, DODS_Time &t2)
 Less-than or Equal-to. More...
 
int operator>= (DODS_Time &t1, DODS_Time &t2)
 Greater-than or Equal-to. More...
 

Detailed Description

The DODS Time object.

This provides a way to translate between various representations of time. This class is designed to be compatible with the DODS_Date class so that dates and times may be used together in relational expressions.

NB: The seconds part of a DODS_Time may contain fractional components. To test for equality of times, this class tests to see if the second time falls within a neighborhood around the first time the size of which is determined by an epsilon value (1.0e-6 by default). Thus seconds may have precision down to the micro-second (depending on the underlying hardware). See the set_epsilon()# and get_epsilon()# mfuncs. The epsilon value is a static class member; the same value is used for all instances of the class, and when changed, is changed at that time for all instances.

See also
DODS_Date
DODS_Date_Time()
Author
James Gallagher

Definition at line 63 of file DODS_Time.h.

Constructor & Destructor Documentation

DODS_Time::DODS_Time ( string  time)

Build a DODS_Time by parsing the String #time#.

The string may be either of the form `hh:mm:ss' or `hh:mm'. In the later case the seconds are assumed to be zero. In addition, the string may have the suffix `GMT' or `UTC' indicating that the time is in Greenwich Mean Time.

Parameters
timeThe time string.
DODS_Time::DODS_Time ( BaseType *  arg)

Build a DODS_Time by parsing the DODS Str #arg#.

See also
DODS_Time(string).
Parameters
argA DODS Str variable, passed as a BaseType pointer.

Definition at line 114 of file DODS_Time.cc.

References set().

Here is the call graph for this function:

DODS_Time::DODS_Time ( dods_uint32  hh,
dods_uint32  mm,
bool  gmt = false 
)

Build a DODS_Time.

Parameters
hhThe hours, 0-23.
mmThe minutes, 0-59.
gmtTrue if the time is a GMT time, false otherwise.

Definition at line 119 of file DODS_Time.cc.

References OK().

Here is the call graph for this function:

DODS_Time::DODS_Time ( dods_uint32  hh,
dods_uint32  mm,
double  ss,
bool  gmt = false 
)

Build a DODS_Time.

Parameters
hhThe hours, 0–23.
mmThe minutes, 0–59.
ssThe seconds, 0–59. May contain a fractional component.
gmtTrue if the time is a GMT time, false otherwise.

Definition at line 129 of file DODS_Time.cc.

References OK().

Here is the call graph for this function:

DODS_Time::DODS_Time ( )

Build an empty DODS_Time.

NB: This won't pass the class invariant.

Definition at line 104 of file DODS_Time.cc.

Member Function Documentation

double DODS_Time::fraction ( ) const

Get the time as a fraction of a day.

Returns
The daytime as a fraction.

Definition at line 94 of file DODS_Time.cc.

Referenced by DODS_Date_Time::get().

string DODS_Time::get ( bool  gmt = true) const

Get the string representation of time.

Parameters
gmtIf true append the suffix `GMT' to the time if it a GMT time. If false, ignore gmt. True by default.
Returns
The string representation for this time.

Definition at line 294 of file DODS_Time.cc.

Referenced by DODS_Date_Time::get().

double DODS_Time::get_epsilon ( ) const

Get the value of epsilon used for equality tests.

Definition at line 211 of file DODS_Time.cc.

Referenced by DODS_Date_Time::get_epsilon().

bool DODS_Time::gmt ( ) const
Returns
True if the time is a GMT time, false otherwise.

Definition at line 288 of file DODS_Time.cc.

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

int DODS_Time::hours ( ) const
Returns
The number of hours.

Definition at line 270 of file DODS_Time.cc.

Referenced by DODS_Date_Time::hours(), and DODS_Date_Time::unix_time().

int DODS_Time::minutes ( ) const
Returns
The number of minutes.

Definition at line 276 of file DODS_Time.cc.

Referenced by DODS_Date_Time::minutes(), and DODS_Date_Time::unix_time().

bool DODS_Time::OK ( ) const

Class invariant.

Returns
True for a valid instance, otherwise false.

Definition at line 85 of file DODS_Time.cc.

Referenced by DODS_Time(), and set().

double DODS_Time::seconds ( ) const
Returns
The number of seconds.

Definition at line 282 of file DODS_Time.cc.

Referenced by DODS_Date_Time::seconds(), and DODS_Date_Time::unix_time().

double DODS_Time::seconds_since_midnight ( ) const

Get the number of seconds since midnight.

Returns
The number of seconds since midnight.

Definition at line 264 of file DODS_Time.cc.

Referenced by DODS_Date_Time::julian_day(), operator<(), operator==(), and operator>().

void DODS_Time::set ( string  time)

Set the value by parsing the string #time#.

Parameters
timeThe time string.
See also
DODS_Time(string).

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

void DODS_Time::set ( BaseType *  arg)

Set the value by parsing the DODS Str #arg#.

Parameters
argThe time string wrapped in a DODS string.
See also
DODS_Time(BaseType *).

Definition at line 184 of file DODS_Time.cc.

References set().

Here is the call graph for this function:

void DODS_Time::set ( int  hh,
int  mm,
bool  gmt = false 
)

Set the value using the given numeric values.

Parameters
hhThe hours, 0-23.
mmThe minutes, 0-59.
gmtTrue if the time is a GMT time, false otherwise.
See also
DODS_Time(int, int, bool).

Definition at line 190 of file DODS_Time.cc.

References set().

Here is the call graph for this function:

void DODS_Time::set ( int  hh,
int  mm,
double  ss,
bool  gmt = false 
)

Set the value using the given numeric values.

Parameters
hhThe hours, 0–23.
mmThe minutes, 0–59.
ssThe seconds, 0–59. May contain a fractional component.
gmtTrue if the time is a GMT time, false otherwise.
See also
DODS_Time(int, int, double, bool).

Definition at line 196 of file DODS_Time.cc.

References gmt(), and OK().

Here is the call graph for this function:

void DODS_Time::set_epsilon ( double  eps)

Set the value of epsilon used for equality tests.

By default the value is 0.000001 (10e-6).

Definition at line 217 of file DODS_Time.cc.

Referenced by DODS_Date_Time::set_epsilon().

Friends And Related Function Documentation

int operator!= ( DODS_Time t1,
DODS_Time t2 
)
friend

Inequality.

Definition at line 230 of file DODS_Time.cc.

int operator< ( DODS_Time t1,
DODS_Time t2 
)
friend

Less-than.

Definition at line 252 of file DODS_Time.cc.

int operator<= ( DODS_Time t1,
DODS_Time t2 
)
friend

Less-than or Equal-to.

Definition at line 258 of file DODS_Time.cc.

int operator== ( DODS_Time t1,
DODS_Time t2 
)
friend

Equality.

Definition at line 223 of file DODS_Time.cc.

int operator> ( DODS_Time t1,
DODS_Time t2 
)
friend

Greater-than.

Definition at line 240 of file DODS_Time.cc.

int operator>= ( DODS_Time t1,
DODS_Time t2 
)
friend

Greater-than or Equal-to.

Definition at line 246 of file DODS_Time.cc.


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