AXCEL C++ Framework
Elegance through abstraction
|
Time keeper. More...
#include <axcel.h>
Public Member Functions | |
virtual string | type () |
Get type of object. | |
virtual | operator string () |
Convert to string. | |
timer () | |
timer (const char *s) | |
int | sec () |
Get seconds. | |
int | min () |
Get minutes. | |
int | hour () |
Get hour. | |
int | mday () |
Get day of the month. | |
int | mon () |
Get month. | |
int | year () |
Get year. | |
int | wday () |
Get weekday. | |
string | str () |
To string. | |
timer & | operator= (const char *s) |
Assign date and time. | |
timer & | operator= (struct tm *tm) |
timer & | operator= (time_t raw) |
bool | operator== (const char *s) |
Compare time. | |
bool | operator!= (const char *s) |
bool | operator> (const char *s) |
bool | operator< (const char *s) |
bool | operator<= (const char *s) |
bool | operator>= (const char *s) |
timer | operator+ (const char *s) |
io::inputcrement Date/Time | |
timer | operator- (const char *s) |
Decrement Date/Time. | |
timer & | operator+= (const char *s) |
timer & | operator-= (const char *s) |
Static Public Member Functions | |
static string | ltime () |
static string | utime () |
Public Attributes | |
bool | UTC |
UTC or Localtime? | |
struct tm | t |
int axcel::timer::hour | ( | ) |
int axcel::timer::mday | ( | ) |
int axcel::timer::min | ( | ) |
int axcel::timer::mon | ( | ) |
axcel::timer::operator string | ( | ) | [virtual] |
Convert to string.
Implements axcel::object.
timer axcel::timer::operator+ | ( | const char * | s | ) |
io::inputcrement Date/Time
s | string describing in English what you want incremented |
The description can be something like "Give me 7 days" or "15 minutes can save you 15 percent or more on car insurance" or "4 hours, 3 days, and 2 hours" or "28 seconds and 8 years". Every unit to increment is the name of the unit (optionally follow by an 's') preceeded by the number of times to increment that unit on a seperate word, all other meaningless words and data are ignored. Valid units include: second, minute, hour, day, month, and year.
timer axcel::timer::operator- | ( | const char * | s | ) |
Decrement Date/Time.
s | string describing in English what you want decremented |
This does the opposite of operator+().
timer & axcel::timer::operator= | ( | const char * | s | ) |
Assign date and time.
s | string representating date & time |
Reads the string specifying the date and time in English and assigns it to this object. When using this operator, struct tm t values are set to 0, so any value not specified in the string (such as second, day of the week, minute, year) remain 0 (or 1 for day of the month).
Example strings: "August 4, 2011 3:59 am", "Today is Monday, the 5th of November", "23:45:89 Sat Feb 4 1978", "Taco Tuesday!!!", "--> Class of 2012 <--", "Apocolypse occurs on Jan 19 03:14:07 2038"
It may seem like magic that this method can parse English into a struct tm but these strings are actually following a strict syntax. A day of the week or month in the string must have its first letter capitalized and can be abbreviated or spelled out. Time must follow the regular expression format:
..?:..?(:..?)? (AM|a[.]?m[.]?|PM|p[.]?m[.]?)?
Meaning that hour and minute must both be specified seperated by ':'. Optionally the second value can follow (prepended with ':') then optionally AM/am/a.m./PM/pm/p.m. can follow after a space.
Any 1 or 2 digit number appearing by itself that is less than 32 is interpreted as the day of the month, otherwise it's interpreted as the year.
bool axcel::timer::operator== | ( | const char * | s | ) |
Compare time.
s | string containing one or more elements from: year, month, day of week, day of month, or time |
Reads string s in same format as described in operator=(). Returns true if the portions of the date/time from that string are the same as those of this object. Example strings: "Is it 2012 yet?", "Friday, Friday, gotta get down on Friday", "Sep", "September", "We will go to the movies at 8:00 pm", "Never forget the 5th of November", "Is it the 16th yet?", "Is it July?"
int axcel::timer::sec | ( | ) |
string axcel::timer::str | ( | ) |
string axcel::timer::type | ( | ) | [virtual] |
int axcel::timer::wday | ( | ) |
int axcel::timer::year | ( | ) |
struct tm axcel::timer::t |
bool axcel::timer::UTC |