#include <lkdatetime.h>
Inheritance diagram for look::LookTime::
Public Methods | |
LookTime (unsigned int theTime=0) | |
Constructor. More... | |
LookTime (unsigned int theHours, unsigned int theMinutes, unsigned int theSeconds=0) | |
Constructor from hours, minutes, seconds. More... | |
LookTime (bool isPM, unsigned int theHours, unsigned int theMinutes=0, unsigned int theSeconds=0) | |
Constructor from 12 hour clock hours, minutes, seconds. More... | |
LookTime (const LookTime &theOther) | |
Copy constructor. | |
~LookTime () | |
Destructor. | |
LookTypeBase* | GetNewCopy (void) const |
Get a new copy. More... | |
long | GetTypeID (void) const |
Get Type ID. More... | |
LookTime& | operator= (const LookTime &theOther) |
Assignment op. | |
bool | operator== (const LookTime &theOther) const |
Equal. | |
bool | operator!= (const LookTime &theOther) const |
Not equal. | |
bool | operator< (const LookTime &theOther) const |
Less than. | |
bool | operator> (const LookTime &theOther) const |
Greater than. | |
bool | operator<= (const LookTime &theOther) const |
Less than or equal. | |
bool | operator>= (const LookTime &theOther) const |
Greater than or equal. | |
LookTime& | operator+= (int theChange) |
Add seconds. | |
LookTime | operator+ (int theChange) const |
Add seconds. | |
int | operator- (LookTime &theOther) const |
Seconds between this and theOther. More... | |
LookTime | operator- (int theChange) const |
Subtract seconds. | |
LookTime& | operator-= (int theChange) |
Subtract seconds. | |
int | Normalise (void) |
Normalise. More... | |
bool | Set (LookString theTimeString) |
Set from a string. More... | |
LookString | GetString (const LookString &theSeparator=":", int thePrecision=3, bool hours24=true) const |
Convert to a string. More... | |
unsigned int | Hours (void) const |
Hours (24H clock). More... | |
unsigned int | Hours12 (void) const |
Hours (12H clock). More... | |
unsigned int | Minutes (void) const |
Minutes (0-59). | |
unsigned int | Seconds (void) const |
Seconds (0-59). | |
bool | isPM (void) const |
Is PM? More... | |
void | SetTime (unsigned int theTime) |
unsigned int | GetTime (void) const |
Static Public Methods | |
LookTime | Now (void) |
Get current time (localtime). | |
Protected Attributes | |
int | itsTime |
Time in seconds since midnight. |
This class represents a time.
It stores its value as the number of seconds since midnight (integral).
|
Constructor. The default value of 0 is midnight.
|
|
Constructor from hours, minutes, seconds. The time is actually calculated as the sum of the hours, minutes and seconds, ie if you give 26 hours, 70 minutes and 90 seconds it will store 97890 seconds since midnight. Hours() will return 27, Minutes() 11, Seconds() 30 and isPM() true (!). Calling Normalise() will fix hours to 3 and isPM() to false, and return the extra day.
|
|
Constructor from 12 hour clock hours, minutes, seconds.
|
|
Get a new copy. Virtual copy constructor, aka clone.
Reimplemented from look::LookTypeBase. |
|
Convert to a string. If the time is not normalised (Normalise()) the results could look odd.
|
|
Get Type ID. Pseudo-rtti, or isA.
Reimplemented from look::LookTypeBase. |
|
Hours (24H clock). If the time is not normalised (Normalise()), this could be < 0 or > 23.
|
|
Hours (12H clock). This will always return 1-12
|
|
Normalise. If the time is constructed with a time outside 00:00:00 - 23:59:59, ie negative seconds or greater than 86400 seconds, or a change has been made to make the time wrap over a day, this converts the time back to within a day. However you don't need to call this after Set() or if you construct with sensible times.
|
|
Set from a string. This can cope with a variety of formats. See LookDateTimeReader for a more general converter. It extracts the first three numbers from theTimeString as hours, minutes and seconds, with numbers being delimited by non-decimal characters. It also finds the last AM and PM (case insensitive). If less than three numbers are found, it uses 0 for the missing ones. Sensible examples of times which will be successfully converted:
|
|
Is PM? It returns true if the time is >= 12 noon. If the time is not normalised (Normalise()), this could return misleading results.
|
|
Seconds between this and theOther. This is negative if theOther is later than this.
|