SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Deprecated. Represents a time, stored as the number of seconds since 00:00:00 January 1, 1901 GMT. More...
#include <rw/rwtime.h>
Public Member Functions | |
RWTime () | |
RWTime (unsigned long s) | |
RWTime (unsigned hour, unsigned minute, unsigned second=0, const RWZone &zone=RWZone::local()) | |
RWTime (const RWDate &date, unsigned hour=0, unsigned minute=0, unsigned second=0, const RWZone &zone=RWZone::local()) | |
RWTime (const RWDate &date, const RWCString &str, const RWZone &zone=RWZone::local(), const RWLocale &locale=RWLocale::global()) | |
RWTime (const struct tm *ptm, const RWZone &zone=RWZone::local()) | |
RWCString | asString (char format= '\0', const RWZone &zone=RWZone::local(), const RWLocale &locale=RWLocale::global()) const |
RWCString | asString (const char *format, const RWZone &zone=RWZone::local(), const RWLocale &locale=RWLocale::global()) const |
bool | between (const RWTime &a, const RWTime &b) const |
RWspace | binaryStoreSize () const |
int | compareTo (const RWTime *t) const |
void | extract (struct tm *ptm, const RWZone &zone=RWZone::local()) const |
unsigned | hash () const |
unsigned | hour (const RWZone &zone=RWZone::local()) const |
unsigned | hourGMT () const |
bool | isDST (const RWZone &zone=RWZone::local()) const |
bool | isValid () const |
RWTime | max (const RWTime &t) const |
RWTime | min (const RWTime &t) const |
unsigned | minute (const RWZone &zone=RWZone::local()) const |
unsigned | minuteGMT () const |
RWTime | operator++ () |
RWTime | operator++ (int) |
RWTime & | operator+= (unsigned long s) |
RWTime | operator-- () |
RWTime | operator-- (int) |
RWTime & | operator-= (unsigned long s) |
unsigned | second () const |
unsigned long | seconds () const |
Static Public Member Functions | |
static RWTime | beginDST (unsigned year, const RWZone &zone=RWZone::local()) |
static RWTime | endDST (unsigned year, const RWZone &zone=RWZone::local()) |
static unsigned | hash (const RWTime &t) |
static RWTime | now () |
Friends | |
bool | operator!= (const RWTime &t1, const RWTime &t2) |
RWTime | operator+ (const RWTime &t, unsigned long s) |
RWTime | operator+ (unsigned long s, const RWTime &t) |
RWTime | operator- (const RWTime &t, unsigned long s) |
bool | operator< (const RWTime &t1, const RWTime &t2) |
std::ostream & | operator<< (std::ostream &s, const RWTime &t) |
bool | operator<= (const RWTime &t1, const RWTime &t2) |
bool | operator== (const RWTime &t1, const RWTime &t2) |
bool | operator> (const RWTime &t1, const RWTime &t2) |
bool | operator>= (const RWTime &t1, const RWTime &t2) |
Related Functions | |
(Note that these are not member functions.) | |
RWvostream & | operator<< (RWvostream &str, const RWTime &t) |
RWFile & | operator<< (RWFile &file, const RWTime &t) |
RWvistream & | operator>> (RWvistream &str, RWTime &t) |
RWFile & | operator>> (RWFile &file, RWTime &t) |
Class RWTime represents a time, stored as the number of seconds since 00:00:00 January 1, 1901 GMT. The Essential Tools User's Guide chapter on date and time classes describes how to set the time zone for your compiler. Failure to do so may result in GMT times being wrong.
Output formatting is done using an RWLocale object. The default locale formats according to U.S. conventions.
Those with access to the C++ Standard Library-based versions of the Essential Tools Module template collections should consider the following:
Thanks to the smart allocation scheme of the standard collections, the above declaration will result in only one call to the default constructor followed by 5000 invocations of the copy constructor. In the case of RWTime, the copy constructor amounts to an assignment of one long
to another, resulting in faster creation than the simple array.
Program output:
|
inline |
Default constructor. Constructs a time with the present time.
|
inline |
Constructs a time with s seconds since 00:00:00 January 1, 1901 GMT. If s == 0
, an invalid time is constructed.
The compiler can parse 0 as either an integer or a pointer. Since there is also a constructor that takes a pointer (to struct tm
, if you want to construct a time from the unsigned long
value 0, you must be explicit:
RWTime::RWTime | ( | unsigned | hour, |
unsigned | minute, | ||
unsigned | second = 0 , |
||
const RWZone & | zone = RWZone::local() |
||
) |
Constructs a time with today's date and the specified hour, minute, and second, relative to the time zone zone, which defaults to local time.
RWTime::RWTime | ( | const RWDate & | date, |
unsigned | hour = 0 , |
||
unsigned | minute = 0 , |
||
unsigned | second = 0 , |
||
const RWZone & | zone = RWZone::local() |
||
) |
Constructs a time for a given date, hour, minute, and second, relative to the time zone zone, which defaults to local time.
RWTime::RWTime | ( | const RWDate & | date, |
const RWCString & | str, | ||
const RWZone & | zone = RWZone::local() , |
||
const RWLocale & | locale = RWLocale::global() |
||
) |
Constructs a time for the given date, extracting the time from the string str. The string str should contain only the time. The time is understood to be relative to the time zone zone, which defaults to local time. The specified locale is used for formatting information. Use function isValid() to check the results.
RWTime::RWTime | ( | const struct tm * | ptm, |
const RWZone & | zone = RWZone::local() |
||
) |
Constructs a time from the tm_year
, tm_mon
, tm_mday
, tm_hour
, tm_min
, and tm_sec
components of the struct tm
argument. These components are understood to be relative to the time zone zone, which defaults to local time.
struct tm
differs from that used in RWTime arguments. RWCString RWTime::asString | ( | char | format = '\0' , |
const RWZone & | zone = RWZone::local() , |
||
const RWLocale & | locale = RWLocale::global() |
||
) | const |
Returns self as a string, formatted by the RWLocale argument, with the time zone adjusted according to the RWZone argument. Formats are as defined by the C++ Standard Library function std::strftime(). The default format is the date followed by the time: "%x %X"
. The exact format of the date and time returned is dependent upon the Locale-dependent %x
and %X
formatting. For more information, see RWLocale.
RWCString RWTime::asString | ( | const char * | format, |
const RWZone & | zone = RWZone::local() , |
||
const RWLocale & | locale = RWLocale::global() |
||
) | const |
|
static |
Returns the start of Daylight Saving Time (DST) for the given year, in the given time zone. Returns an "invalid time" if DST is not observed in that year and zone.
Returns true
if RWTime is between a and b, inclusive.
|
inline |
Returns the number of bytes necessary to store the object using the global function
int RWTime::compareTo | ( | const RWTime * | t | ) | const |
Compares self to the contents of t, returning a value from the table below based on the result of the comparison.
0 | self == *t |
<0 | self < *t |
>0 | self > *t |
|
static |
Returns the end of Daylight Saving Time for the given year, in the given time zone. Returns an "invalid time" if DST is not observed in that year and zone.
void RWTime::extract | ( | struct tm * | ptm, |
const RWZone & | zone = RWZone::local() |
||
) | const |
unsigned RWTime::hash | ( | ) | const |
Returns a suitable hashing value.
|
static |
Returns the hash value of t as returned by t.hash().
unsigned RWTime::hour | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the hour, adjusted to the time zone specified.
unsigned RWTime::hourGMT | ( | ) | const |
Returns the hour in GMT.
bool RWTime::isDST | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns true
if self is during Daylight Saving Time in the time zone given by zone, false
otherwise.
|
inline |
Returns true
if this is a valid time, false
otherwise.
unsigned RWTime::minute | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the minute, adjusted to the time zone specified.
unsigned RWTime::minuteGMT | ( | ) | const |
Returns the minute in GMT.
|
static |
Returns the present time.
|
inline |
Prefix increment operator. Adds one second to self, then returns the results.
|
inline |
Postfix increment operator. Adds one second to self, returning the initial value.
|
inline |
Adds s seconds to self, returning self.
|
inline |
Prefix decrement operator. Subtracts one second from self, then returns the results.
|
inline |
Postfix decrement operator. Subtracts one second from self, returning the initial value.
|
inline |
Subtracts s seconds from self, returning self.
unsigned RWTime::second | ( | ) | const |
Returns the second in local time or GMT.
|
inline |
Returns the number of seconds since 00:00:00 January 1, 1901 GMT.
Returns true
if t1 is not equal to t2.
Returns an RWTime s seconds greater than t.
Returns an RWTime s seconds greater than t.
Returns an RWTime s seconds less than t.
|
friend |
Outputs the time t on ostream
s, according to the locale imbued in the stream (see class RWLocale), or by RWLocale::global() if none.
|
related |
Saves an RWTime t onto the virtual stream str.
Returns true
if t1 is less than or equal to t2.
Returns true
if t1 is greater than t2.
Returns true
if t1 is greater than or equal to t2.
|
related |
Restores an RWTime into t from the virtual stream str, replacing the previous contents of t.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |