Evo C++ Library v0.5.1
|
#include <evo/time.h>
Full calendar date and time of day with timezone offset.
Output:
Public Member Functions | |
DateTime () | |
Constructor. More... | |
DateTime (int year, int month, int day, int hour=0, int minute=0, int second=0, int msecond=0, int tz_offset=OFFSET_NULL) | |
Constructor. More... | |
DateTime (const DateTime &src) | |
Copy constructor. More... | |
DateTime (const Date &date) | |
Date constructor. More... | |
DateTime (const Date &date, const TimeOfDay &time) | |
Date and TimeOfDay constructor. More... | |
DateTime (const Date &date, const TimeOfDay &time, const TimeZoneOffset &tz) | |
Date and TimeOfDay constructor. More... | |
DateTime (const TimeZoneOffset &tz) | |
Timezone offset constructor. More... | |
bool | add_days (int days) |
Add days to current date, subtract if negative. More... | |
bool | add_hours (int hours) |
Add hours to current date and time, subtract if negative. More... | |
bool | add_milliseconds (int msec) |
Add milliseconds to current date and time, subtract if negative. More... | |
bool | add_minutes (int minutes) |
Add minutes to current date and time, subtract if negative. More... | |
bool | add_months (int months) |
Add months to current date, subtract if negative. More... | |
bool | add_seconds (int seconds) |
Add seconds to current date and time, subtract if negative. More... | |
bool | add_years (int years) |
Add years to current date, subtract if negative. More... | |
int | compare (const DateTime &oth) const |
Compare to another date and time. More... | |
template<class T > | |
T & | format (T &out, char dt_delim='T', char d_delim='-', char t_delim=':', char msec_delim=0, char tz_delim=':') const |
Format date and time to String or Stream using given delimiters. More... | |
template<class T > | |
T & | format_nodelim (T &out, char dt_delim='T', char msec_delim=0) const |
Format date and time to String or Stream using standard delimiters. More... | |
template<class T > | |
T & | format_std (T &out, char dt_delim='T', char msec_delim=0) const |
Format date and time to String or Stream using standard delimiters. More... | |
double | get_jdn_dt () const |
Get Julian Day Number with time fraction. More... | |
bool | operator!= (const DateTime &oth) const |
Compare for inequality with another date and time. More... | |
bool | operator< (const DateTime &oth) const |
Compare whether less than another date and time. More... | |
bool | operator<= (const DateTime &oth) const |
Compare whether less than or equal to another date and time. More... | |
DateTime & | operator= (const DateTime &src) |
Assignment operator. More... | |
bool | operator== (const DateTime &oth) const |
Compare for equality with another date and time. More... | |
bool | operator> (const DateTime &oth) const |
Compare whether greater than another date and time. More... | |
bool | operator>= (const DateTime &oth) const |
Compare whether greater than or equal to another date and time. More... | |
bool | parse (const SubString &str) |
Set date/time from parsing standard ISO 8601 based string. More... | |
bool | parse_std_impl (const char *&inp, const char *end) |
Set date/time from parsing standard ISO 8601 based string. More... | |
DateTime & | set () |
Set all fields to 0, which is not a validate but is a valid time (midnight) and timezone offset (UTC). More... | |
bool | set (int year, int month, int day, int hour=0, int minute=0, int second=0, int msecond=0) |
Set new new fields. More... | |
bool | set_jdn_dt (double tm, int msec=0) |
Set new fields from Julian Day Number. More... | |
DateTime & | set_local () |
Set to current local date and time with time zone offset. More... | |
DateTime & | set_local_notz () |
Set to current local date and time without time zone offset. More... | |
DateTime & | set_utc () |
Set to current UTC date and time. More... | |
bool | validate () const |
Validate current date, time, and timezone offset. More... | |
Public Attributes | |
Date | date |
Date fields. More... | |
TimeOfDay | time |
TimeOfDay fields. More... | |
TimeZoneOffset | tz |
TimeZoneOffset fields. More... | |
Static Public Attributes | |
static const ulong | JDN_MIN = Date::JDN_MIN |
Minimum Julian Day Number for Jan 1, 1000. More... | |
static const int | OFFSET_NULL = TimeZoneOffset::OFFSET_NULL |
Null time zone offset. More... | |
|
inline |
Constructor.
|
inline |
Constructor.
year | 4 digit year |
month | Month of year |
day | Day of month |
hour | Hour of day |
minute | Minute of hour |
second | Second of minute |
msecond | Millisecond of second |
tz_offset | Time zone offset from UTC in minutes, 0 for UTC, negative for the Western Hemisphere (America), positive for the remaining time zones, OFFSET_NULL for null (no time zone) |
|
inline |
|
inline |
Timezone offset constructor.
tz | Timezone offset to copy from |
|
inline |
Add days to current date, subtract if negative.
days | Number of days to add, negative to subtract |
|
inline |
Add hours to current date and time, subtract if negative.
hours | Number of hours to add, negative to subtract |
|
inline |
Add milliseconds to current date and time, subtract if negative.
msec | Number of milliseconds to add, negative to subtract |
|
inline |
Add minutes to current date and time, subtract if negative.
minutes | Number of minutes to add, negative to subtract |
|
inline |
Add months to current date, subtract if negative.
months | Number of months to add, negative to subtract |
|
inline |
Add seconds to current date and time, subtract if negative.
seconds | Number of seconds to add, negative to subtract |
|
inline |
Add years to current date, subtract if negative.
years | Number of years to add, negative to subtract |
|
inline |
Compare to another date and time.
oth
have different time zone offsets, the differnce is taken into account, as if both are converted to UTC for comparisonoth | Other date and time to compare to |
|
inline |
Format date and time to String or Stream using given delimiters.
1999-12-31T23:59:59Z
1999-12-31T23:59:59+07:30
1999-12-31T23:59:59-08:00
T | String/Stream type, inferred from argument |
out | Output String/Stream to format to |
dt_delim | Delimiter between date and time, ISO 8601 uses T , Evo also supports space and underscore |
d_delim | Date field delimiter, usually - , 0 for none – see Date::format() |
t_delim | TimeOfDay field delimiter, usually : , 0 for none – see TimeOfDay::format() |
msec_delim | Milliseconds delimiter, can be . or , , 0 for none – see TimeOfDay::format() |
tz_delim | TimeZoneOffset field delimiter, usually : , 0 for none – see TimeZoneOffset::format() |
out
|
inline |
Format date and time to String or Stream using standard delimiters.
19991231T235959Z
19991231T235959+07:30
19991231T235959-08:00
T | String/Stream type, inferred from argument |
out | Output String/Stream to format to |
dt_delim | Delimiter between date and time, ISO 8601 uses T , Evo also supports space and underscore |
msec_delim | Milliseconds delimiter, can be . or , , 0 for none – see TimeOfDay::format() |
out
|
inline |
Format date and time to String or Stream using standard delimiters.
_
and .
delimiters:1999-12-31_23:59:59.999Z
1999-12-31_23:59:59.999+07:30
1999-12-31_23:59:59.999-08:00
T | String/Stream type, inferred from argument |
out | Output String/Stream to format to |
dt_delim | Delimiter between date and time, ISO 8601 uses T , Evo also supports space and underscore |
msec_delim | Milliseconds delimiter, can be . or , , 0 for none – see TimeOfDay::format() |
out
|
inline |
Get Julian Day Number with time fraction.
|
inline |
Compare for inequality with another date and time.
oth | Other date and time to compare to |
|
inline |
Compare whether less than another date and time.
oth
have different time zone offsets, the differnce is taken into account, as if both are converted to UTC for comparisonoth | Other date and time to compare to |
|
inline |
Compare whether less than or equal to another date and time.
oth
have different time zone offsets, the differnce is taken into account, as if both are converted to UTC for comparisonoth | Other date and time to compare to |
Assignment operator.
src | Source to copy |
|
inline |
Compare for equality with another date and time.
oth | Other date and time to compare to |
|
inline |
Compare whether greater than another date and time.
oth
have different time zone offsets, the differnce is taken into account, as if both are converted to UTC for comparisonoth | Other date and time to compare to |
|
inline |
Compare whether greater than or equal to another date and time.
oth
have different time zone offsets, the differnce is taken into account, as if both are converted to UTC for comparisonoth | Other date and time to compare to |
|
inline |
Set date/time from parsing standard ISO 8601 based string.
DATE "T" TIME TZ
(without quotes or spaces)DATE
: YYYY-MM-DD
– see Date::parse() for more variations and detailTIME
: HH:MM:SS
or HH:MM:SS.fff
– see TimeOfDay::parse() for more variations and detailTZ
: Z
or +HH:MM
or -HH:MM
– see TimeZoneOffset::parse() for more variations and detailstr | String to parse |
|
inline |
Set date/time from parsing standard ISO 8601 based string.
DATE "T" TIME TZ
(without quotes or spaces)DATE
: YYYY-MM-DD
– see Date::parse() for more variations and detailTIME
: HH:MM:SS
or HH:MM:SS.fff
– see TimeOfDay::parse() for more variations and detailTZ
: Z
or +HH:MM
or -HH:MM
– see TimeZoneOffset::parse() for more variations and detailinp | Start parsing pointer (must be <= end ), set to stop position [in/out] |
end | End of string pointer, must not be NULL |
|
inline |
Set all fields to 0, which is not a validate but is a valid time (midnight) and timezone offset (UTC).
|
inline |
Set new new fields.
tz
)year | 4 digit year |
month | Month of year |
day | Day of month |
hour | Hour of day |
minute | Minute of hour |
second | Second of minute |
msecond | Millisecond of second |
|
inline |
Set new fields from Julian Day Number.
tz
)time.msecond
is set from msec
tm | Julian Day Number with whole number as date and fraction for time since midight – must not be negative |
msec | Milliseconds to set (0 - 999), defaults to 0 |
tm
is invalid (0 or less than JDN_MIN)
|
inline |
Set to current local date and time with time zone offset.
|
inline |
Set to current local date and time without time zone offset.
|
inline |
Set to current UTC date and time.
|
inline |
Validate current date, time, and timezone offset.
|
static |
Minimum Julian Day Number for Jan 1, 1000.
|
static |
Null time zone offset.
TimeZoneOffset fields.