libdballe 9.6
|
#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. | |
void | set_lower_bound () |
Fill possibly missing fields with their lowest valid value. | |
void | set_upper_bound () |
Fill possibly missing fields with their highest valid value. | |
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. | |
bool | operator== (const Datetime &o) const |
bool | operator!= (const Datetime &o) const |
bool | operator< (const Datetime &o) const |
bool | operator> (const Datetime &o) const |
bool | operator<= (const Datetime &o) const |
bool | operator>= (const Datetime &o) const |
int | print_iso8601 (FILE *out, char sep='T', const char *end="\n") const |
Print to an output stream in ISO8601 combined format. | |
int | print (FILE *out, 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. | |
void | to_csv_iso8601 (CSVWriter &out, char sep='T', const char *tz="") const |
Write the datetime as a CSV field in ISO8601 date format. | |
std::string | to_string (char sep='T', const char *tz="") const |
Write to a string in ISO8601 combined format. | |
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. | |
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. | |
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. | |
Public Attributes | |
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.
out | the output stream |
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.