|
| Time (const String &fmt, const String &str) |
| Constructor. More...
|
|
| Time (uint_t year, uint_t month=1, uint_t day=1, uint_t hour=0, uint_t min=0, double sec=0, bool isGMT=false) |
| Constructor. More...
|
|
| Time (time_t t) |
| Constructor. More...
|
|
virtual int | compare (const Object &rhs) const |
| Compare with another object. More...
|
|
virtual void | copy (const Object &rhs) |
| Copy another instance. More...
|
|
virtual void | serialize (Stream &stream, uint_t io, uint_t mode=ser_default) |
| Serialize to or from a stream. More...
|
|
|
| operator time_t () const |
| Return a time_t representation. More...
|
|
time_t | get () const |
| Get the time as a time_t value. More...
|
|
void | getComponents (uint_t *year, uint_t *month, uint_t *day, uint_t *wday=nullptr, uint_t *hour=nullptr, uint_t *min=nullptr, double *sec=nullptr, bool *isDST=nullptr, bool isGMT=false) const |
| Get the year, month, and day. More...
|
|
bool | isNull () const |
| Get the Null flag. More...
|
|
void | setNull () |
| Set to null. More...
|
|
uint_t | getYear () const |
| Get the year. More...
|
|
uint_t | getMonth () const |
| Get the month. More...
|
|
uint_t | getDay () const |
| Get the day. More...
|
|
uint_t | getDayOfWeek () const |
| Get the day of week [0 = Sunday, . More...
|
|
uint_t | getHour () const |
| Get the hour [0,23]. More...
|
|
uint_t | getMin () const |
| Get the minute [0,59]. More...
|
|
uint_t | getSec () const |
| Get the second [0,59]. More...
|
|
uint_t | getTimeOfDay () const |
| Get the number of seconds since midnight. More...
|
|
uint_t | maxDay () const |
| Get the last day of this month. More...
|
|
void | set (time_t dateTime) |
| Set with a time_t value. More...
|
|
void | set (uint_t year, uint_t month, uint_t day, uint_t hour=0, uint_t min=0, double sec=0, bool isGMT=false) |
| Set a new date/time. More...
|
|
Time & | setCurrent () |
| Set to the current time. More...
|
|
|
virtual String | toString () const |
| Return a string representation of self. More...
|
|
String | toString (const String &fmt) const |
| Return a string representation of self. More...
|
|
String | toGMTstring () const |
| Return a string represenation of self (in GMT). More...
|
|
String | toGMTstring (const String &fmt) const |
| Return a string representation of self. More...
|
|
void | set (const String &fmt, const String &str) |
| Set with a string. More...
|
|
|
Time & | roundDown (uint_t unit) |
| Round down to the given unit. More...
|
|
Time & | roundDown (const Duration &dur) |
| Round down to the given resolution. More...
|
|
Time & | roundUp (uint_t unit) |
| Round up to the given unit. More...
|
|
Time & | roundUp (const Duration &dur) |
| Round up to the given resolution. More...
|
|
|
Time & | operator= (time_t t) |
| Assignment from time_t. More...
|
|
Time | operator+ (int i) const |
| Return self plus the given number of seconds. More...
|
|
Time | operator+ (const Duration &rhs) const |
| Return self plus the given duration. More...
|
|
Time | operator- (const Duration &rhs) const |
| Return self minus the given duration. More...
|
|
Time | operator- (int i) const |
| Return self minus the given number of seconds. More...
|
|
Duration | operator- (const Time &rhs) const |
| Return self minus the given time. More...
|
|
const Time & | operator+= (const Duration &rhs) |
| Add the given duration to self. More...
|
|
const Time & | operator-= (const Duration &rhs) |
| Subtract the given duration from self. More...
|
|
void | clear () |
| Revert to initial state. More...
|
|
virtual void | vclone (const Object &rhs) |
| Make an exact copy of another instance. More...
|
|
virtual void | steal (Object &rhs) |
| "Steal" the internal representation from another instance. More...
|
|
virtual void | dump (Stream &os, uint_t level=uint_t_max) const |
| Dump a human-readable representation of self to the given output stream. More...
|
|
void | dumpWithClassName (Stream &os, uint_t indent=4, uint_t level=uint_t_max) const |
| Front-end for dump() that prints the object's class name. More...
|
|
virtual const Object & | getKey () const |
| Get the key for this object. More...
|
|
bool | hasKey () const |
| Determine whether or not the object has a key. More...
|
|
virtual const Object & | getProxiedObject () const |
| Get the proxied object (= self if none). More...
|
|
virtual Object & | getProxiedObject () |
| Get the proxied object (= self if none). More...
|
|
virtual size_t | hash (size_t size) const |
| Get the hash code for the object. More...
|
|
bool | _isA (const RunTimeClass *runTimeClass) const |
| Determine whether self's class is a descendent of the given class. More...
|
|
| operator String () const |
| Conversion to String. More...
|
|
size_t | allocatedSize () const |
| Get the total allocated size of this object. More...
|
|
virtual size_t | innerAllocatedSize () const |
| Get the "inner" allocated size. More...
|
|
virtual void | addOwnedIt (const class FwdIt *it) const |
| Notify self that it owns the given iterator. More...
|
|
virtual void | removeOwnedIt (const class FwdIt *it) const |
| Notify self that the given owned iterator has been destroyed. More...
|
|
bool | operator< (const Object &rhs) const |
| Less-than operator. More...
|
|
bool | operator<= (const Object &rhs) const |
| Less-than-or-equal-to operator. More...
|
|
bool | operator> (const Object &rhs) const |
| Greater-than operator. More...
|
|
bool | operator>= (const Object &rhs) const |
| Greater-than-or-equal-to operator. More...
|
|
bool | operator== (const Object &rhs) const |
| Equal-to operator. More...
|
|
bool | operator!= (const Object &rhs) const |
| Unequal-to operator. More...
|
|
void | serializeIn (Stream &is, uint_t mode=ser_default) |
| Serialize from an input stream. More...
|
|
void | serializeOut (Stream &os, uint_t mode=ser_default) const |
| Serialize to an output stream. More...
|
|
void | serializeOutBoxed (Stream &os, uint_t mode=ser_default) const |
| Serialize a boxed object to an output stream. More...
|
|
Date/time.
Getting a String Representation
A format string given to the toString() method contains special codes that are to be substituted with strings based on the represented time. The codes are always preceded by a $ character so the parser can recognize them. If you want to have a $ character in the format string without a format code, just put two in a row: $$.
The formatting codes for toString() are:
- d : day of month [1,31]
- dd : day of month (2 digits)
- dst : " DST" if DST enabled
- h : hour [0,23]
- hh : hour [0,11]
- Mn : month name
- mn : abbreviated month name (e.g. "Jan")
- m : month [1,12]
- mm : month (2 digits)
- n : minute [0,59]
- nn : minute (2 digits)
- P : "AM" or "PM"
- p : "am" or "pm"
- s : second [0,59]
- ss : second (2 digits)
- Wn : day of week (e.g. "Monday")
- wn : abbreviated day of week (e.g. "Mon")
- y : year (e.g. 05 => 2005)
- yyyy : year (4 digits - e.g. "2005")
For example, suppose the represented time is June 15th 2000 5:43 pm DST. Here are some format strings and the corresponding results that toString() would provide.
- "year = $yyyy, month = $Mn" => "year = 2000, month = June"
- "$mn $d, $yyyy @ $hh:$mm" => "Jun 15, 2000 @ 17:43"
- "$h:$mm $p $DST" => "5:43 pm DST"
Setting Time With a String
When setting the time with a string, you provide two strings to set(). The first string is the format string that tells the parser what to expect in the second string which contains the string representation of the time. The formatting codes are not preceded by a $ character as they are with toString() because the format string contains only formatting codes.
Here are the format strings recognized by set():
- y : year (2 or 4 digits)
- Mn : month name (e.g. "January")
- mn : abbreviated month name (e.g. "Jan")
- m : month [1,12]
- d : day [1,31]
- h : hour [0,23]
- n : minute [0,59]
- s : second [0,59]
- p : am or pm (case-insensitive)
- gmt : interpret as GMT
- Author
- Adam McKee
Definition at line 148 of file Time.h.