|
libdballe
7.7
|
#include <types.h>
Public Member Functions | |
| Datetime () | |
| Construct a missing datetime. | |
| Datetime (const Date &date, const Time &time) | |
| Datetime (int ye, int mo=1, int da=1, int ho=0, int mi=0, int se=0) | |
| Construct from broken down values. More... | |
| Date | date () const |
| Return a Date with this date. | |
| Time | time () const |
| Return a Time with this time. | |
| bool | is_missing () const |
| Check if this datetime is the missing value. | |
| int | to_julian () const |
| Convert the date to Julian day. | |
| int | compare (const Datetime &other) const |
| Generic comparison. More... | |
| bool | operator== (const Datetime &dt) const |
| bool | operator!= (const Datetime &dt) const |
| bool | operator< (const Datetime &dt) const |
| bool | operator> (const Datetime &dt) const |
| bool | operator<= (const Datetime &dt) const |
| bool | operator>= (const Datetime &dt) const |
| void | print_iso8601 (FILE *out, char sep='T', const char *end="\n") const |
| Print to an output stream in ISO8601 combined format. | |
| void | to_stream_iso8601 (std::ostream &out, char sep='T', const char *tz="") const |
| Write the datetime to an output stream in ISO8601 combined format. More... | |
Static Public Member Functions | |
| static Datetime | from_julian (int jday, int ho=0, int mi=0, int se=0) |
| Set the date from a Julian day. | |
| static Datetime | lower_bound (int ye, int mo, int da, int ho, int mi, int se) |
| Return a Datetime filling the parts set to MISSING_INT with their lowest possible values. | |
| static Datetime | upper_bound (int ye, int mo, int da, int ho, int mi, int se) |
| Return a Datetime filling the parts set to MISSING_INT with their highest possible values. | |
| static Datetime | from_iso8601 (const char *str) |
| Parse an ISO8601 datetime string. More... | |
| static void | validate (int ye, int mo, int da, int ho, int mi, int se) |
| Raise an exception if the three values do not represent a valid date/time. More... | |
| static void | normalise_h24 (int &ye, int &mo, int &da, int &ho, int &mi, int &se) |
| Convert a datetime with an hour of 24:00:00 to hour 00:00:00 of the following day. | |
Data Fields | |
| unsigned short | year |
| unsigned char | month |
| unsigned char | day |
| unsigned char | hour |
| unsigned char | minute |
| unsigned char | second |
Date and time.
If year is 0xffff, then all the datetime is considered missing. Else, all fields must be set.
| dballe::Datetime::Datetime | ( | int | ye, |
| int | mo = 1, |
||
| int | da = 1, |
||
| int | ho = 0, |
||
| int | mi = 0, |
||
| int | se = 0 |
||
| ) |
Construct from broken down values.
A year of MISSING_INT constructs a missing Datetime. In any other case, arguments are validated with Datetime::validate().
| int dballe::Datetime::compare | ( | const Datetime & | other | ) | const |
Generic comparison.
Returns a negative number if *this < other Returns zero if *this == other Returns a positive number if *this > other
|
static |
Parse an ISO8601 datetime string.
Both 'T' and ' ' are allowed as separators.
| void dballe::Datetime::to_stream_iso8601 | ( | std::ostream & | out, |
| char | sep = 'T', |
||
| const char * | tz = "" |
||
| ) | const |
Write the datetime to an output stream in ISO8601 combined format.
| sep | the separator character between date and time |
| tz | the timezone string to use at the end of the datetime |
|
static |
Raise an exception if the three values do not represent a valid date/time.
A value of 23:59:60 is allowed to accomodate for times during leap seconds, but no effort is made to check if there has been a leap second on the given date.
1.8.9.1