AXCEL C++ Framework
Elegance through abstraction
Public Member Functions | Static Public Member Functions | Public Attributes
axcel::timer Class Reference

Time keeper. More...

#include <axcel.h>

Inheritance diagram for axcel::timer:
axcel::object

List of all members.

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.
timeroperator= (const char *s)
 Assign date and time.
timeroperator= (struct tm *tm)
timeroperator= (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.
timeroperator+= (const char *s)
timeroperator-= (const char *s)

Static Public Member Functions

static string ltime ()
static string utime ()

Public Attributes

bool UTC
 UTC or Localtime?
struct tm t

Detailed Description

Time keeper.

Definition at line 998 of file axcel.h.


Constructor & Destructor Documentation

axcel::timer::timer ( )

Definition at line 5175 of file axcel.cpp.

axcel::timer::timer ( const char *  s)

Definition at line 5176 of file axcel.cpp.


Member Function Documentation

int axcel::timer::hour ( )

Get hour.

Returns:
Number of hours past midnight (0 - 23)

Definition at line 5190 of file axcel.cpp.

string axcel::timer::ltime ( ) [static]

Definition at line 5436 of file axcel.cpp.

int axcel::timer::mday ( )

Get day of the month.

Returns:
Day of the month (1 - 31)

Definition at line 5195 of file axcel.cpp.

int axcel::timer::min ( )

Get minutes.

Returns:
Number of minutes after the hour (0 - 59)

Definition at line 5185 of file axcel.cpp.

int axcel::timer::mon ( )

Get month.

Returns:
Number of months since January (0 - 11)

Definition at line 5200 of file axcel.cpp.

axcel::timer::operator string ( ) [virtual]

Convert to string.

Returns:
Suitable string representation of object's data

Implements axcel::object.

Definition at line 287 of file axcel.cpp.

bool axcel::timer::operator!= ( const char *  s)

Definition at line 5364 of file axcel.cpp.

timer axcel::timer::operator+ ( const char *  s)

io::inputcrement Date/Time

Parameters:
sstring describing in English what you want incremented
Returns:
New timer object result

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.

Definition at line 5375 of file axcel.cpp.

timer & axcel::timer::operator+= ( const char *  s)

Definition at line 5429 of file axcel.cpp.

timer axcel::timer::operator- ( const char *  s)

Decrement Date/Time.

Parameters:
sstring describing in English what you want decremented
Returns:
New timer object result

This does the opposite of operator+().

Definition at line 5405 of file axcel.cpp.

timer & axcel::timer::operator-= ( const char *  s)

Definition at line 5430 of file axcel.cpp.

bool axcel::timer::operator< ( const char *  s)

Definition at line 5361 of file axcel.cpp.

bool axcel::timer::operator<= ( const char *  s)

Definition at line 5362 of file axcel.cpp.

timer & axcel::timer::operator= ( struct tm *  tm)

Definition at line 5467 of file axcel.cpp.

timer & axcel::timer::operator= ( time_t  raw)

Definition at line 5431 of file axcel.cpp.

timer & axcel::timer::operator= ( const char *  s)

Assign date and time.

Parameters:
sstring representating date & time
Returns:
Reference to this object

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.

Definition at line 5267 of file axcel.cpp.

bool axcel::timer::operator== ( const char *  s)

Compare time.

Parameters:
sstring containing one or more elements from: year, month, day of week, day of month, or time
Returns:
true if Requested fields are the same value as those of this object

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?"

Definition at line 5337 of file axcel.cpp.

bool axcel::timer::operator> ( const char *  s)

Definition at line 5360 of file axcel.cpp.

bool axcel::timer::operator>= ( const char *  s)

Definition at line 5363 of file axcel.cpp.

int axcel::timer::sec ( )

Get seconds.

Returns:
Number of seconds after the minute (0 - 59)

Definition at line 5180 of file axcel.cpp.

string axcel::timer::str ( )

To string.

Returns:
string representing the date and time associated with this object

Definition at line 5215 of file axcel.cpp.

string axcel::timer::type ( ) [virtual]

Get type of object.

Returns:
string containing name of object's class.

Implements axcel::object.

Definition at line 261 of file axcel.cpp.

string axcel::timer::utime ( ) [static]

Definition at line 5451 of file axcel.cpp.

int axcel::timer::wday ( )

Get weekday.

Returns:
Number of days since Sunday (0 - 6)

Definition at line 5210 of file axcel.cpp.

int axcel::timer::year ( )

Get year.

Returns:
Number of years since 1900

Definition at line 5205 of file axcel.cpp.


Member Data Documentation

struct tm axcel::timer::t

Definition at line 1011 of file axcel.h.

UTC or Localtime?

After assigning time to this object you should set this variable to true if the time represents UTC time or false if it represents Local time.

Definition at line 1008 of file axcel.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Defines