Go to the previous, next section.
#include <nihcl/Time.h>
Instances of class
Time
represent a time of day, internally represented as the number of seconds elapsed since January 1, 1901, 00:00:00 GMT. Times through December 31, 2036, 23:59:59 GMT can be represented.
Class
Time
provides a complete set of arithmetic and relational operators along with member functions for converting a
Time
to a
Date
, obtaining the local or GMT hour, minute, and second, and printing a
Time
.
Member functions of class
Time
use the following data types:
typedef unsigned short hourTy; typedef unsigned short minuteTy; typedef unsigned short secondTy; typedef unsigned long clockTy; // seconds elapsed since // 1-Jan-01 GMT
Time()
Time
for the current time.
Time(clockTy
s)
Time
for
s
seconds since January 1, 1901, 00:00:00 GMT.
Time(hourTy
h, minuteTy
m, secondTy
s
=0, bool
dst
=NO)
Time
for today at the specfied (local) hour
h, minute
m, and second
s. The argument
dst
is ignored unless Daylight Savings Time (DST) is observed locally and it is between 1:00 AM and 1:59 AM on the day when the transition from DST to Standard Time occurs, currently the last Sunday in October. In this case,
dst
=
YES
indicates DST and
dst
=
NO
indicates Standard Time.
If DST is observed locally, an
NIHCL_BADTIME
exception is raised if the specified time is between 1:00 AM and 1:59 AM on the day when the transition from Standard Time to DST occurs, currently the last Sunday in April.
Time(const Date&
d, hourTy
h
=0, minuteTy
m
=0, secondTy
s
=0, bool
dst
=NO)
Time
for the
Date
d
at the specfied (local) hour
h, minute
m, and second
s. The argument
dst
is ignored unless Daylight Savings Time is observed locally and it is between 1:00 AM and 1:59 AM on the day when the transition from DST to Standard Time occurs, currently the last Sunday in October. In this case,
dst
=
YES
indicates DST and
dst
=
NO
indicates Standard Time.
If DST is observed locally, an
NIHCL_BADTIME
exception is raised if the time specified is between 1:00 AM and 1:59 AM on the day when the transition from Standard Time to DST occurs, currently the last Sunday in April. An
NIHCL_DATERANGE
exception is raised if the
Date
specified is before January 1, 1901, 00:00:00 GMT or after December 31, 2036, 23:59:59 GMT.
friend Time operator+(const Time&
t, long
s)
friend Time operator+(long
s, const Time&
t)
Time
that is
s
seconds after the
Time
t
if
s
is positive, or
s
seconds before
t
if
s
is negative.
Time operator-(long
s) const
Time
that is
s
seconds before the
Time
t
if
s
is positive, or
s
seconds after
t
if
s
is negative.
long operator-(const Time&) const
Time
and the argument
Time
. The result is negative if the argument
Time
is later than this
Time
.
void operator+=(long
s)
Time
by one that is
s
seconds after this
Time
if
s
is positive, or
s
seconds before this
Time
if
s
is negative.
void operator-=(long s)
Time
by one that is
s
seconds before this
Time
if
s
is positive, or
s
seconds after this
Time
if
s
is negative.
virtual unsigned hash() const
bool operator<(const Time&) const
bool operator<=(const Time&) const
bool operator>(const Time&) const
bool operator>=(const Time&) const
bool operator==(const Time&) const
bool operator!=(const Time&) const
YES
if the indicated relation holds between this
Time
and the argument
Time
.
Time max(const Time&
t) const
Time
and the argument
Time
.
Time min(const Time&
t) const
Time
and the argument
Time
.
virtual int compare(const Object&
ob) const
Time
with the argument object
ob, which must also be an instance of class
Time
. Returns a negative result if this
Time
is earlier than
ob, zero if this
Time
equals
ob, and a positive result if this
Time
is later than
ob.
bool between(const Time&
min, const Time&
max) const
YES
if this
Time
is later than or equal to
min
and earlier than or equal to
max.
virtual bool isEqual(const Object&
ob) const
YES
if
ob
is of species
Time
and equals this
Time
.
operator Date() const
Time
to an instance of class
Date
.
hourTy hour() const
minuteTy minute() const
secondTy second() const
Time
adjusted to the local time zone.
hourTy hourGMT() const
minuteTy minuteGMT() const
secondTy second() const
Time
in Greenwich Mean Time (GMT).
clockTy seconds() const
Time
.
virtual void deepenShallowCopy()
Time
.
virtual void printOn(ostream&
strm
=cout)
Time
adjusted to the local time zone on the output stream
strm
in the 24-hour format HH:MM:SS.
virtual const Class* species() const
Time
.
virtual void storer(OIOofd&
fd) const
virtual void storer(OIOout&
strm) const
Time
on
fd
or
strm.
NIHCL_DATERANGE
,
NIHCL_BADTIME
Go to the previous, next section.