Inheritance diagram for lfc::Time::
Public Types | |
enum | Month { January, February, March, April, May, June, July, August, September, October, November, December } |
months constants. More... | |
Public Methods | |
Time () throw () | |
Time (const Time &t) throw () | |
Time (int year, Month month, int day, int hour=0, int min=0, int sec=0) | |
virtual | ~Time () throw () |
virtual short | year () const throw () |
| |
virtual short | month () const throw () |
| |
virtual short | day () const throw () |
| |
virtual short | hour () const throw () |
| |
virtual short | minute () const throw () |
| |
virtual short | second () const throw () |
| |
virtual short | dayOfTheWeek () const throw () |
| |
virtual short | dayOfTheYear () const throw () |
| |
virtual void | setYear (int year) |
sets the current year inside the object, if valid. More... | |
virtual void | setMonth (Month month) |
sets the current month inside the object, if valid. More... | |
virtual void | setDay (int day) |
sets the current day of the month inside the object, if valid. More... | |
virtual void | setHour (int hour) |
sets the current hour inside the object, if valid. More... | |
virtual void | setMinute (int min) |
sets the current minute inside the object, if valid. More... | |
virtual void | setSecond (int sec) |
sets the current second inside the object, if valid. More... | |
virtual const string | monthName (short monthIndex) const |
| |
virtual const string | dayName (short dayIndex) const |
| |
virtual bool | operator== (const Time &t) const throw () |
virtual bool | operator< (const Time &t) const throw () |
virtual const Time & | operator= (const Time &t) throw () |
virtual const TimeSpan | operator- (const Time &t) const |
virtual const Time | operator+ (const TimeSpan &ts) const |
virtual const Time | operator- (const TimeSpan &ts) const |
virtual void | update () throw () |
updates the current object to the system's current date/time. More... | |
virtual void | writeObject (BinaryOutput &stream) const |
platform independent serialization. More... | |
virtual void | readObject (BinaryInput &stream) |
platform independent deserialization. More... | |
virtual void | formatObject (TextOutput &stream, string format="") const |
formatting based on a certain format. More... | |
virtual void | scanObject (TextInput &stream, string format="") |
scanning based on a certain format. More... | |
Protected Methods | |
virtual short | monthIndex (const string &monthName) const |
Protected Attributes | |
time_t | m_time |
Static Protected Attributes | |
const time_t | NULL_TIME = time_t(-1) |
a representation of an invalid date/time value. More... |
Here's a small sample of how to use Time:
Time t(2016, Time::December, 25); Console console; TextOutput to(console); to << "In 2016, Christmas will be on a " << t.dayName(t.dayOfTheWeek()) << ".\n" << "Unfortunately, 'till then we'll have to wait for:\n" << formattedOut(t - Time(), "-d 'days', -h 'hours', -m 'minutes and' -s 'seconds'") << ENDL << "That's a pretty long time, isn't it ? :)" << ENDL;
|
months constants.
|
|
|
|
|
|
You must provide valid values, otherwise an TimeException will be thrown.
|
|
|
|
|
|
- 0 = January - 1 = February ... - 11 = December |
|
|
|
|
|
|
|
|
|
- 0 = Sunday - 1 = Monday ... - 6 = Saturday |
|
- 0 = January 1 - 1 = January 2 ... - 365 = December 31 |
|
sets the current year inside the object, if valid.
|
|
sets the current month inside the object, if valid.
|
|
sets the current day of the month inside the object, if valid.
|
|
sets the current hour inside the object, if valid.
|
|
sets the current minute inside the object, if valid.
|
|
sets the current second inside the object, if valid.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updates the current object to the system's current date/time.
|
|
platform independent serialization.
Reimplemented from lfc::_Serializable. |
|
platform independent deserialization.
Reimplemented from lfc::_Serializable. |
|
formatting based on a certain format. The format must be as follows:
Symbol Meaning Presentation Example ------ ------- ------------ ------- y year Number 1996 yy abbreviated year Number 96 M month in year Number 07 MM month in year Text July d day in month Number 10 h hour in am/pm (1~12) Number 12 H hour in day (0~23) Number 0 m minute in hour Number 30 s second in minute Number 55 S millisecond Number 978 E day in week Text Tuesday a am marker Text AM p pm marker Text PM ' escape for text Text 'seconds' '' single quote Text ' Any characters in the pattern that are not in this formatting list will be treated as quoted text. For instance, characters like ':', ',', '.', ' ', '#' and '@' will appear in the resulting time text even they are not embraced within single quotes. Examples:
Format Pattern Result -------------- ------ "y.M.d 'at' H:m:s" ->> "1996.07.10 at 15:08:56" "E, MM d, ''yy" ->> "Wed, July 10, '96" "h:m p" ->> "11:08 PM" "h 'o''''clock' a" ->> "11 o'clock AM" "y.MM.d h:m a" ->> "1996.July.10 11:08 AM" Reimplemented from lfc::_Formatable. |
|
scanning based on a certain format. The format used for scanning is identical to that used for formatting and if the format or the data coming from the stream are invalid, an TimeException will be thrown. If you wonder how an valid scanning format for Time looks like, here goes:
Reimplemented from lfc::_Scanable. |
|
|
|
a representation of an invalid date/time value.
|
|
|