Webmaster  |  Imprint 
Platinum
Platinum C++ Framework
Main  |  License  |  Documentation  |  Download  |  Support 

Time Class Reference
[DateTime]

Time expressed in hours, minutes, seconds and milliseconds

#include <Pt/Time.h>

List of all members.

Public Member Functions

 Time ()
 Creates a Time set to zero.
 Time (unsigned hour, unsigned min, unsigned ses=0, unsigned msec=0)
 Creates a Time from given values.
unsigned hour () const
 Returns the hour-part of the Time.
unsigned minute () const
 Returns the minute-part of the Time.
unsigned second () const
 Returns the second-part of the Time.
unsigned msec () const
 Returns the millisecond-part of the Time.
unsigned totalMSecs () const
void setTotalMSecs (unsigned msecs)
void set (unsigned hour, unsigned min, unsigned sec, unsigned mssec=0)
 Sets the time.
void get (unsigned &h, unsigned &m, unsigned &s, unsigned &ms) const
 Get the time values.
Time addSecs (int secs) const
 Adds seconds to the time.
int secsTo (const Time &) const
 Determines seconds until another time.
Time addMSecs (Pt::int64_t ms) const
 Adds milliseconds to the time.
Pt::int64_t msecsTo (const Time &) const
 Determines milliseconds until another time.
Timeoperator= (const Time &other)
 Assignment operator.
bool operator== (const Time &other) const
 Equal comparison operator.
bool operator!= (const Time &other) const
 Inequal comparison operator.
bool operator< (const Time &other) const
 Less-than comparison operator.
bool operator<= (const Time &other) const
 Less-than-or-equal comparison operator.
bool operator> (const Time &other) const
 Greater-than comparison operator.
bool operator>= (const Time &other) const
 Greater-than-or-equal comparison operator.
Timeoperator+= (const Timespan &ts)
 Assignment by sum operator.
Timeoperator-= (const Timespan &ts)
 Assignment by difference operator.
std::string toIsoString () const
 Returns the time in ISO-format (hh:mm:ss.hhh).

Static Public Member Functions

static bool isValid (unsigned h, unsigned m, unsigned s, unsigned ms=0)
 Returns true if values are a valid time.
static Time fromIsoString (const std::string &s)
 Convert from an ISO time string.

Static Public Attributes

static const unsigned MaxHours = 23
static const unsigned HoursPerDay = 24
static const unsigned MaxMinutes = 59
static const unsigned MinutesPerHour = 60
static const unsigned MinutesPerDay = 1440
static const unsigned MaxSeconds = 59
static const unsigned SecondsPerDay = 86400
static const unsigned SecondsPerHour = 3600
static const unsigned SecondsPerMinute = 60
static const unsigned MSecsPerDay = 86400000
static const unsigned MSecsPerHour = 3600000
static const unsigned MSecsPerMinute = 60000
static const unsigned MSecsPerSecond = 1000

Friends

Time operator+ (const Time &time, const Timespan &ts)
 Addition operator.
Time operator- (const Time &time, const Timespan &ts)
 Substraction operator.
Timespan operator- (const Time &a, const Time &b)
 Substraction operator.


Constructor & Destructor Documentation

Time ( unsigned  hour,
unsigned  min,
unsigned  ses = 0,
unsigned  msec = 0 
)

InvalidTime is thrown if one or more of the values are out of range


Member Function Documentation

void set ( unsigned  hour,
unsigned  min,
unsigned  sec,
unsigned  mssec = 0 
)

Sets the time to a new hour, minute, second, milli-second. InvalidTime is thrown if one or more of the values are out of range

void get ( unsigned &  h,
unsigned &  m,
unsigned &  s,
unsigned &  ms 
) const

Gets the hour, minute, second and millisecond parts of the time.

Time addSecs ( int  secs  )  const

This method does not change the time, but returns the time with the seconds added.

Time addMSecs ( Pt::int64_t  ms  )  const

This method does not change the time, but returns the time with the milliseconds added.

static Time fromIsoString ( const std::string &  s  )  [static]

Interprets the passed string as a time-string in ISO-format (hh:mm:ss.hhh) and returns a Time-object. If the string is not in ISO-format, InvalidTime is thrown.

Copyright © 2003-2007 The Pt Development Team
Pt 1.0