libdcp
|
A representation of a local time (down to the second), including its offset from GMT (equivalent to xs:dateTime). More...
#include <local_time.h>
Public Member Functions | |
LocalTime () | |
LocalTime (struct tm tm) | |
LocalTime (boost::posix_time::ptime) | |
LocalTime (boost::posix_time::ptime, int tz_hour, int tz_minute) | |
LocalTime (std::string s) | |
std::string | as_string (bool with_millisecond=false) const |
std::string | date () const |
std::string | time_of_day (bool with_second, bool with_millisecond) const |
int | day () const |
int | month () const |
int | year () const |
int | hour () const |
int | minute () const |
int | second () const |
void | set_year (int y) |
void | add_days (int d) |
void | add_months (int a) |
void | add_minutes (int a) |
bool | operator== (LocalTime const &other) const |
bool | operator!= (LocalTime const &other) const |
bool | operator< (LocalTime const &other) const |
Static Public Member Functions | |
static LocalTime | from_asn1_utc_time (std::string time) |
static LocalTime | from_asn1_generalized_time (std::string time) |
Private Member Functions | |
void | set (struct tm const *tm) |
void | set (boost::posix_time::ptime) |
void | set_local_time_zone () |
Private Attributes | |
int | _year = 0 |
year | |
int | _month = 0 |
month number of the year (1-12) | |
int | _day = 0 |
day number of the month (1-31) | |
int | _hour = 0 |
hour number of the day (0-23) | |
int | _minute = 0 |
minute number of the hour (0-59) | |
int | _second = 0 |
second number of the minute (0-59) | |
int | _millisecond = 0 |
millisecond number of the second (0-999) | |
int | _tz_hour = 0 |
hours by which this time is offset from UTC; can be negative | |
int | _tz_minute = 0 |
Friends | |
class | ::local_time_basic_test |
A representation of a local time (down to the second), including its offset from GMT (equivalent to xs:dateTime).
I tried to use boost for this, really I did, but I could not get it to parse strings of the required format (those that include time zones).
See http://www.w3.org/TR/xmlschema-2/#dateTime
Definition at line 63 of file local_time.h.
LocalTime::LocalTime | ( | ) |
Construct a LocalTime from the current time
Definition at line 56 of file local_time.cc.
|
explicit |
Construct a LocalTime from a boost::posix_time::ptime using the local time zone
Definition at line 85 of file local_time.cc.
LocalTime::LocalTime | ( | boost::posix_time::ptime | t, |
int | tz_hour, | ||
int | tz_minute | ||
) |
Construct a LocalTime from a boost::posix_time::ptime and a time zone offset
tz_minute | Offset from UTC in minutes; if the timezone is behind UTC this may be negative, e.g. -04:30 would have tz_hour=-1 and tz_minute=-30. |
Definition at line 106 of file local_time.cc.
|
explicit |
s | A string of the form 2013-01-05T18:06:59[.123][+04:00] |
Definition at line 127 of file local_time.cc.
string LocalTime::as_string | ( | bool | with_millisecond = false | ) | const |
Definition at line 186 of file local_time.cc.
string LocalTime::date | ( | ) | const |
Definition at line 199 of file local_time.cc.
|
private |
Set our UTC offset to be according to the local time zone
Definition at line 116 of file local_time.cc.
string LocalTime::time_of_day | ( | bool | with_second, |
bool | with_millisecond | ||
) | const |
Definition at line 208 of file local_time.cc.
|
private |
Minutes by which this time is offset from UTC; if _tz_hour is negative this will be either 0 or negative.
Definition at line 153 of file local_time.h.