bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
DODS_Time Class Reference

#include <DODS_Time.h>

Collaboration diagram for DODS_Time:
Collaboration graph

Public Member Functions

Constructors
 DODS_Time (string time)
 
 DODS_Time (BaseType *arg)
 
 DODS_Time (dods_uint32 hh, dods_uint32 mm, bool gmt=false)
 
 DODS_Time (dods_uint32 hh, dods_uint32 mm, double ss, bool gmt=false)
 
 DODS_Time ()
 
Assignment
void set (string time)
 
void set (BaseType *arg)
 
void set (int hh, int mm, bool gmt=false)
 
void set (int hh, int mm, double ss, bool gmt=false)
 
Access
string get (bool gmt=true) const
 
int hours () const
 
int minutes () const
 
double seconds () const
 
bool gmt () const
 
double seconds_since_midnight () const
 
double fraction () const
 

Relational operators

bool OK () const
 
double get_epsilon () const
 
void set_epsilon (double eps)
 
int operator== (DODS_Time &t1, DODS_Time &t2)
 Equality.
 
int operator!= (DODS_Time &t1, DODS_Time &t2)
 Inequality.
 
int operator< (DODS_Time &t1, DODS_Time &t2)
 Less-than.
 
int operator> (DODS_Time &t1, DODS_Time &t2)
 Greater-than.
 
int operator<= (DODS_Time &t1, DODS_Time &t2)
 Less-than or Equal-to.
 
int operator>= (DODS_Time &t1, DODS_Time &t2)
 Greater-than or Equal-to.
 

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

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

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.

◆ DODS_Time() [3/5]

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.

◆ DODS_Time() [4/5]

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.

◆ DODS_Time() [5/5]

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

◆ fraction()

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.

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

◆ get_epsilon()

double DODS_Time::get_epsilon ( ) const

Get the value of epsilon used for equality tests.

Definition at line 211 of file DODS_Time.cc.

◆ gmt()

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.

◆ hours()

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

Definition at line 270 of file DODS_Time.cc.

◆ minutes()

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

Definition at line 276 of file DODS_Time.cc.

◆ OK()

bool DODS_Time::OK ( ) const

Class invariant.

Returns
True for a valid instance, otherwise false.

Definition at line 85 of file DODS_Time.cc.

◆ seconds()

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

Definition at line 282 of file DODS_Time.cc.

◆ seconds_since_midnight()

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.

◆ set() [1/4]

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.

◆ set() [2/4]

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.

◆ set() [3/4]

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.

◆ set() [4/4]

void DODS_Time::set ( string time)

Set the value by parsing the string #time#.

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

Definition at line 140 of file DODS_Time.cc.

◆ set_epsilon()

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.

Friends And Related Symbol Documentation

◆ operator!=

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

Inequality.

Definition at line 230 of file DODS_Time.cc.

◆ operator<

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

Less-than.

Definition at line 251 of file DODS_Time.cc.

◆ operator<=

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

Less-than or Equal-to.

Definition at line 257 of file DODS_Time.cc.

◆ operator==

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

Equality.

Definition at line 223 of file DODS_Time.cc.

◆ operator>

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

Greater-than.

Definition at line 240 of file DODS_Time.cc.

◆ operator>=

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: