Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide

RWTime

Module:  Essential Tools Module   Group:  Date and Time


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/rwtime.h>
RWTime a;   // Construct with current time

Description

Class RWTime represents a time, stored as the number of seconds since 00:00:00 January 1, 1901 GMT. The User's Guide chapter on date and time classes describes how to set the time zone for your compiler. Failure to do this may result in GMT times being wrong.


NOTE -- RWTime measures time in seconds since 1/1/1970 in a 32 bit integer. This representation will overflow shortly after 2037. For applications that need time ranges greater than this, the Essential Tools Module now includes the RWDateTime class, which combines functionality from RWDate and RWTime but with a much greater range and millisecond accuracy. RWTime will be deprecated in a future major release of the Essential Tools Module.

Output formatting is done using an RWLocale object. The default locale formats according to U.S. conventions.

Note that because the default constructor for this class creates an instance holding the current date and time, constructing a large array of RWTime may be slow.

Those with access to the Standard C++ 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.

Persistence

Simple

Example

This example constructs a current time, and the time when Daylight Saving Time starts in the year 1990. It then prints them out.

Program output

Public Constructors

RWTime();
RWTime(const 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& = RWZone::local());
RWTime(const struct tm*, const RWZone& = RWZone::local());
RWTime(const RWDate& date, const RWCString& str,
       const RWZone& zone = RWZone::local(),
       const RWLocale& locale = RWLocale::global());

Public Member Operators

RWTime&
operator=(const RWTime&);
RWTime
operator++();
RWTime
operator--();
RWTime
operator++(int);
RWTime
operator--(int);
RWTime&
operator+=(unsigned long s);
RWTime&
operator-=(unsigned long s);

Public Member Functions

RWCString
asString(char format = '\0',const RWZone& =
         RWZone::local(),
         const RWLocale& = RWLocale::global()) const;
RWCString
asString(char* format,const RWZone&   = RWZone::local(),
         const RWLocale& = RWLocale::global()) const;
RWBoolean
between(const RWTime& a, const RWTime& b) const;
size_t
binaryStoreSize() const;
int
compareTo(const RWTime* t) const;
void
extract(struct tm*,const RWZone& = RWZone::local()) const;
unsigned
hash() const;
unsigned
hour(const RWZone& zone = RWZone::local()) const;
unsigned
hourGMT() const;
RWBoolean
isDST(const RWZone& zone = RWZone::local()) const;
RWBoolean
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;
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& = RWZone::local());
static unsigned
hash(const RWTime& t);
static RWTime
now();

Related Global Operators

RWTime
operator+(const RWTime& t, unsigned long s);
RWTime
operator+(unsigned long s, const RWTime& t);
RWTime
operator-(const RWTime& t, unsigned long s);
RWBoolean
operator<(const RWTime& t1, const RWTime& t2);
RWBoolean
operator<=(const RWTime& t1, const RWTime& t2);
RWBoolean
operator>(const RWTime& t1, const RWTime& t2);
RWBoolean
operator>=(const RWTime& t1, const RWTime& t2);
RWBoolean
operator==(const RWTime& t1, const RWTime& t2);
RWBoolean
operator!= (const RWTime& t1, const RWTime& t2);
ostream&
operator<<(ostream& s, const RWTime& t);
istream&
operator>>(istream&, RWTime&);
RWvostream&
operator<<(RWvostream&, const RWTime& t);
RWFile&
operator<<(RWFile&,     const RWTime& t);
RWvistream&
operator>>(RWvistream&, RWTime& t);
RWFile&
operator>>(RWFile&,     RWTime& t);


Previous fileTop of DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.