In file DODS_Time.h:

class DODS_Time

The DODS Time object

Public Methods

bool OK() const
Class invariant
double get_epsilon() const
Get the value of epsilon used for equality tests
void set_epsilon(double eps)
Set the value of epsilon used for equality tests

Public

Constructors
DODS_Time(String time)
Build a DODS\_Time by parsing the String #time#
DODS_Time(BaseType *arg)
Build a DODS\_Time by parsing the DODS Str #arg#
DODS_Time(int hh, int mm, bool gmt = false)
Build a DODS\_Time
DODS_Time(int hh, int mm, double ss, bool gmt = false)
Build a DODS\_Time
DODS_Time()
Build an empty DODS\_Time
Assignment
void set(String time)
Set the value by parsing the String #time#
void set(BaseType *arg)
Set the value by parsing the DODS Str #arg#
void set(int hh, int mm, bool gmt = false)
Set the value using the given numeric values
void set(int hh, int mm, double ss, bool gmt = false)
Set the value using the given numeric values
Access
String get(bool gmt = true) const
Get the string representation of time
int hours() const
int minutes() const
double seconds() const
bool gmt() const
double seconds_since_midnight() const
Get the number of seconds since midnight
Relational operators
friend int operator==(DODS_Time &t1, DODS_Time &t2)
Equality
friend int operator!=(DODS_Time &t1, DODS_Time &t2)
Inequality
friend int operator<(DODS_Time &t1, DODS_Time &t2)
Less-than
friend int operator>(DODS_Time &t1, DODS_Time &t2)
Greater-than
friend int operator<=(DODS_Time &t1, DODS_Time &t2)
Less-than or Equal-to
friend int operator>=(DODS_Time &t1, DODS_Time &t2)
Greater-than or Equal-to

Documentation

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

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:
time - The time string.

DODS_Time(BaseType *arg)
Build a DODS\_Time by parsing the DODS Str #arg#.
Parameters:
arg - A DODS Str variable, passed as a BaseType pointer.
See Also:
DODS_Time(String).

DODS_Time(int hh, int mm, bool gmt = false)
Build a DODS\_Time.
Parameters:
hh - The hours, 0-23.
mm - The minutes, 0-59.
gmt - True if the time is a GMT time, false otherwise.

DODS_Time(int hh, int mm, double ss, bool gmt = false)
Build a DODS\_Time.
Parameters:
hh - The hours, 0--23.
mm - The minutes, 0--59.
ss - The seconds, 0--59. May contain a fractional component.
gmt - True if the time is a GMT time, false otherwise.

DODS_Time()
Build an empty DODS\_Time. NB: This won't pass the class invariant.

Assignment

void set(String time)
Set the value by parsing the String #time#.
Parameters:
time - The time string.
See Also:
DODS_Time(String).

void set(BaseType *arg)
Set the value by parsing the DODS Str #arg#.
Parameters:
arg - The time string wrapped in a DODS String.
See Also:
DODS_Time(BaseType *).

void set(int hh, int mm, bool gmt = false)
Set the value using the given numeric values.
Parameters:
hh - The hours, 0-23.
mm - The minutes, 0-59.
gmt - True if the time is a GMT time, false otherwise.
See Also:
DODS_Time(int, int, bool).

void set(int hh, int mm, double ss, bool gmt = false)
Set the value using the given numeric values.
Parameters:
hh - The hours, 0--23.
mm - The minutes, 0--59.
ss - The seconds, 0--59. May contain a fractional component.
gmt - True if the time is a GMT time, false otherwise.
See Also:
DODS_Time(int, int, double, bool).

Access

String get(bool gmt = true) const
Get the string representation of time.
Returns:
The string representation for this time.
Parameters:
gmt - If true append the suffix `GMT' to the time if it a GMT time. If false, ignore gmt. True by default.

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

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

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

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

double seconds_since_midnight() const
Get the number of seconds since midnight
Returns:
The number of seconds since midnight.

Relational operators

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

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

friend int operator<(DODS_Time &t1, DODS_Time &t2)
Less-than

friend int operator>(DODS_Time &t1, DODS_Time &t2)
Greater-than

friend int operator<=(DODS_Time &t1, DODS_Time &t2)
Less-than or Equal-to

friend int operator>=(DODS_Time &t1, DODS_Time &t2)
Greater-than or Equal-to

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

double get_epsilon() const
Get the value of epsilon used for equality tests

void set_epsilon(double eps)
Set the value of epsilon used for equality tests. By default the value is 0.000001 (10e-6).


This class has no child classes.
Author:
James Gallagher
See Also:
DODS_Date
DODS_Date_Time()

alphabetic index hierarchy of classes


generated by doc++