OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TTime Class Reference

The TTime class encapsulates time functions and characteristics. More...

#include <owl/time.h>

Public Member Functions

friend TDate::TDate (const TTime &)
 
 TTime ()
 Construct TTime with current time (seconds since Jan 1, 1901).
 
 TTime (const TSystemTime &t)
 from SYSTEMTIME
 
 TTime (const TFileTime &t)
 from FILETIME
 
 TTime (ClockTy s)
 Constructs a TTime object with the given s (seconds since January 1, 1901).
 
 TTime (HourTy h, MinuteTy m, SecondTy s=0)
 Specified time and today's date:
 
 TTime (const TDate &, HourTy h=0, MinuteTy m=0, SecondTy s=0)
 Construct a Time for the specified (local) Date, hour, minute, and second.
 
TSystemTime GetSystemTime () const
 
TFileTime GetFileTime () const
 
tstring AsString () const
 Returns a string object containing the time.
 
int CompareTo (const TTime &) const
 Compares t to this TTime object and returns 0 if the times are equal, 1 if t is earlier, and -1 if t is later.
 
unsigned Hash () const
 Hash function: Returns seconds since January 1, 1901.
 
HourTy Hour () const
 Returns the hour in local time.
 
HourTy HourGMT () const
 Returns the hour in Greenwich mean time.
 
int IsDST () const
 Returns 1 if the time is in daylight saving time; 0 otherwise.
 
int IsValid () const
 Returns 1 if this TTime object contains a valid time, 0 otherwise.
 
TTime Max (const TTime &t) const
 Returns either this TTime object or t, whichever is greater.
 
TTime Min (const TTime &t) const
 Returns either this TTime object or t, whichever is less.
 
MinuteTy Minute () const
 Returns the minute in local time.
 
MinuteTy MinuteGMT () const
 Returns the minute in Greenwich Mean Time.
 
SecondTy Second () const
 Returns seconds.
 
ClockTy Seconds () const
 Returns seconds since January 1, 1901.
 
int operator< (const TTime &t) const
 Returns 1 if the target time is less than time t, 0 otherwise.
 
int operator<= (const TTime &t) const
 Returns 1 if the target time is less than or equal to time t, 0 otherwise.
 
int operator> (const TTime &t) const
 Returns 1 if the target time is greater than time t, 0 otherwise.
 
int operator>= (const TTime &t) const
 Returns 1 if the target time is greater than or equal to time t, 0 otherwise.
 
int operator== (const TTime &t) const
 Returns 1 if the target time is equal to time t, 0 otherwise.
 
int operator!= (const TTime &t) const
 Returns 1 if the target time is not equal to time t, 0 otherwise.
 
int Between (const TTime &a, const TTime &b) const
 Returns 1 if the target date is between TTime a and TTime b, 0 otherwise.
 
void operator++ ()
 Increments the time by 1 second.
 
void operator-- ()
 Decrements the time by 1 second.
 
void operator+= (long s)
 Adds s seconds to the time.
 
void operator-= (long s)
 Subtracts s seconds from the time.
 

Static Public Member Functions

static TTime BeginDST (unsigned year)
 Return the time at which DST starts for the given year.
 
static TTime EndDST (unsigned year)
 Return the time at which DST ends for the given year.
 
static int PrintDate (int)
 Set flag to 1 to print the date along with the time; set to 0 to not print the date.
 

Static Protected Member Functions

static int AssertDate (const TDate &)
 Returns 1 if d is between the earliest valid date (RefDate) and the latest valid date (MaxDate).
 

Static Protected Attributes

static const TDate RefDate
 The minimum valid date for TTime objects: January 1, 1901.
 
static const TDate MaxDate
 The maximum valid date for TTime objects.
 

Friends

tostreamoperator<< (tostream &, const TTime &)
 Inserts time t into output stream os.
 
opstreamoperator<< (opstream &s, const TTime &d)
 
ipstreamoperator>> (ipstream &s, TTime &d)
 
TTime operator+ (const TTime &t, long s)
 Adds s seconds to time t.
 
TTime operator+ (long s, const TTime &t)
 Adds s seconds to time t.
 
TTime operator- (const TTime &t, long s)
 Performs subtraction, in seconds, between s and t.
 
TTime operator- (long s, const TTime &t)
 Performs subtraction, in seconds, between s and t.
 

Detailed Description

The TTime class encapsulates time functions and characteristics.

Definition at line 38 of file time.h.

Constructor & Destructor Documentation

◆ TTime() [1/6]

owl::TTime::TTime ( )

Construct TTime with current time (seconds since Jan 1, 1901).

Definition at line 137 of file time.cpp.

References TTime(), owl::TSystemTime::LocalTime(), and TDate::TDate().

◆ TTime() [2/6]

owl::TTime::TTime ( const TSystemTime & t)

◆ TTime() [3/6]

owl::TTime::TTime ( const TFileTime & t)

◆ TTime() [4/6]

owl::TTime::TTime ( ClockTy s)
inline

Constructs a TTime object with the given s (seconds since January 1, 1901).

Definition at line 119 of file time.h.

◆ TTime() [5/6]

owl::TTime::TTime ( HourTy h,
MinuteTy m,
SecondTy s = 0 )

Specified time and today's date:

Definition at line 166 of file time.cpp.

References TTime(), and TDate::TDate().

◆ TTime() [6/6]

owl::TTime::TTime ( const TDate & date,
HourTy h = 0,
MinuteTy m = 0,
SecondTy s = 0 )

Construct a Time for the specified (local) Date, hour, minute, and second.

Note
this algorithm will fail if DST correction is something other than an hour. It is complicated by the DST boundary problem:
  • 1) Times in the phantom zone between 2AM and 3AM when DST is invoked are invalid.
  • 2) Times in the hour after 1AM when DST ends, are redundant.

Checking for these situations necessitates a lot of jumping back and forth by an hour to check for the boundary.

Definition at line 182 of file time.cpp.

References IsDST(), owl::TDate::IsValid(), RefDate, and owl::SECONDS_IN_DAY.

Member Function Documentation

◆ AssertDate()

int owl::TTime::AssertDate ( const TDate & date)
staticprotected

Returns 1 if d is between the earliest valid date (RefDate) and the latest valid date (MaxDate).

Definition at line 62 of file time.cpp.

References owl::TDate::Between(), MaxDate, and RefDate.

◆ AsString()

tstring owl::TTime::AsString ( ) const

Returns a string object containing the time.

Definition at line 29 of file timeio.cpp.

◆ BeginDST()

TTime owl::TTime::BeginDST ( unsigned year)
static

Return the time at which DST starts for the given year.

Note that the time returned is the time at which DST starts locally, but it is returned in GMT.

Definition at line 100 of file time.cpp.

References TDate::TDate().

◆ Between()

int owl::TTime::Between ( const TTime & a,
const TTime & b ) const
inline

Returns 1 if the target date is between TTime a and TTime b, 0 otherwise.

Definition at line 174 of file time.h.

◆ CompareTo()

int owl::TTime::CompareTo ( const TTime & t) const

Compares t to this TTime object and returns 0 if the times are equal, 1 if t is earlier, and -1 if t is later.

Definition at line 248 of file time.cpp.

◆ EndDST()

TTime owl::TTime::EndDST ( unsigned year)
static

Return the time at which DST ends for the given year.

Note that the time returned is the time at which DST ends locally, but it is returned in GMT.

Definition at line 124 of file time.cpp.

◆ GetFileTime()

TFileTime owl::TTime::GetFileTime ( ) const

Definition at line 238 of file time.cpp.

References GetSystemTime().

◆ GetSystemTime()

TSystemTime owl::TTime::GetSystemTime ( ) const

Definition at line 218 of file time.cpp.

References Hour(), Minute(), and Second().

◆ Hash()

unsigned owl::TTime::Hash ( ) const

Hash function: Returns seconds since January 1, 1901.

Definition at line 258 of file time.cpp.

◆ Hour()

HourTy owl::TTime::Hour ( ) const

Returns the hour in local time.

Definition at line 266 of file time.cpp.

References owl::SECONDS_IN_DAY.

◆ HourGMT()

HourTy owl::TTime::HourGMT ( ) const

Returns the hour in Greenwich mean time.

Definition at line 274 of file time.cpp.

References owl::SECONDS_IN_DAY.

◆ IsDST()

int owl::TTime::IsDST ( ) const

Returns 1 if the time is in daylight saving time; 0 otherwise.

Definition at line 282 of file time.cpp.

References BeginDST(), EndDST(), owl::SECONDS_IN_DAY, and TDate::TDate().

◆ IsValid()

int owl::TTime::IsValid ( ) const
inline

Returns 1 if this TTime object contains a valid time, 0 otherwise.

Todo
Why not return bool?

Definition at line 126 of file time.h.

◆ Max()

TTime owl::TTime::Max ( const TTime & t) const

Returns either this TTime object or t, whichever is greater.

Definition at line 296 of file time.cpp.

◆ Min()

TTime owl::TTime::Min ( const TTime & t) const

Returns either this TTime object or t, whichever is less.

Definition at line 305 of file time.cpp.

◆ Minute()

MinuteTy owl::TTime::Minute ( ) const

Returns the minute in local time.

Definition at line 316 of file time.cpp.

References owl::SECONDS_IN_DAY.

◆ MinuteGMT()

MinuteTy owl::TTime::MinuteGMT ( ) const

Returns the minute in Greenwich Mean Time.

Definition at line 324 of file time.cpp.

References owl::SECONDS_IN_DAY.

◆ operator!=()

int owl::TTime::operator!= ( const TTime & t) const
inline

Returns 1 if the target time is not equal to time t, 0 otherwise.

Definition at line 168 of file time.h.

◆ operator++()

void owl::TTime::operator++ ( )
inline

Increments the time by 1 second.

Definition at line 204 of file time.h.

◆ operator+=()

void owl::TTime::operator+= ( long s)
inline

Adds s seconds to the time.

Definition at line 216 of file time.h.

◆ operator--()

void owl::TTime::operator-- ( )
inline

Decrements the time by 1 second.

Definition at line 210 of file time.h.

◆ operator-=()

void owl::TTime::operator-= ( long s)
inline

Subtracts s seconds from the time.

Definition at line 222 of file time.h.

◆ operator<()

int owl::TTime::operator< ( const TTime & t) const
inline

Returns 1 if the target time is less than time t, 0 otherwise.

Definition at line 138 of file time.h.

◆ operator<=()

int owl::TTime::operator<= ( const TTime & t) const
inline

Returns 1 if the target time is less than or equal to time t, 0 otherwise.

Definition at line 144 of file time.h.

◆ operator==()

int owl::TTime::operator== ( const TTime & t) const
inline

Returns 1 if the target time is equal to time t, 0 otherwise.

Definition at line 162 of file time.h.

◆ operator>()

int owl::TTime::operator> ( const TTime & t) const
inline

Returns 1 if the target time is greater than time t, 0 otherwise.

Definition at line 150 of file time.h.

◆ operator>=()

int owl::TTime::operator>= ( const TTime & t) const
inline

Returns 1 if the target time is greater than or equal to time t, 0 otherwise.

Definition at line 156 of file time.h.

◆ PrintDate()

int owl::TTime::PrintDate ( int f)
static

Set flag to 1 to print the date along with the time; set to 0 to not print the date.

Returns the old setting.

Definition at line 69 of file timeio.cpp.

◆ Second()

SecondTy owl::TTime::Second ( ) const

Returns seconds.

Definition at line 332 of file time.cpp.

References owl::SECONDS_IN_DAY.

◆ Seconds()

ClockTy owl::TTime::Seconds ( ) const
inline

Returns seconds since January 1, 1901.

Definition at line 132 of file time.h.

◆ TDate::TDate()

owl::TTime::TDate::TDate ( const TTime & )

Friends And Related Symbol Documentation

◆ operator+ [1/2]

TTime operator+ ( const TTime & t,
long s )
friend

Adds s seconds to time t.

Definition at line 180 of file time.h.

◆ operator+ [2/2]

TTime operator+ ( long s,
const TTime & t )
friend

Adds s seconds to time t.

Definition at line 186 of file time.h.

◆ operator- [1/2]

TTime operator- ( const TTime & t,
long s )
friend

Performs subtraction, in seconds, between s and t.

Definition at line 192 of file time.h.

◆ operator- [2/2]

TTime operator- ( long s,
const TTime & t )
friend

Performs subtraction, in seconds, between s and t.

Definition at line 198 of file time.h.

◆ operator<< [1/2]

opstream & operator<< ( opstream & s,
const TTime & d )
friend

Definition at line 17 of file timep.cpp.

◆ operator<< [2/2]

tostream & operator<< ( tostream & s,
const TTime & t )
friend

Inserts time t into output stream os.

Definition at line 41 of file timeio.cpp.

◆ operator>>

ipstream & operator>> ( ipstream & s,
TTime & d )
friend

Definition at line 23 of file timep.cpp.

Member Data Documentation

◆ MaxDate

const TDate owl::TTime::MaxDate
staticprotected

The maximum valid date for TTime objects.

Definition at line 104 of file time.h.

◆ RefDate

const TDate owl::TTime::RefDate
staticprotected

The minimum valid date for TTime objects: January 1, 1901.

Definition at line 103 of file time.h.


The documentation for this class was generated from the following files: