|
GnuCash
5.6-150-g038405b370+
|
GnuCash DateTime class. More...
#include <gnc-datetime.hpp>
Public Member Functions | |
| GncDateTime () | |
| Construct a GncDateTime representing the current time in the current timezone. | |
| GncDateTime (const time64 time) | |
| Construct a GncDateTime in the current timezone representing the timestamp as seconds from the POSIX epoch (1970-01-01T00:00:00UTC). More... | |
| GncDateTime (const struct tm tm) | |
| Construct a GncDateTime in the current timezone representing the standard struct tm provided. More... | |
| GncDateTime (const GncDate &date, DayPart part=DayPart::neutral) | |
| Construct a GncDateTime from a GncDate. More... | |
| GncDateTime (const std::string &str) | |
| Construct a GncDateTime. More... | |
| GncDateTime (const char *str) | |
| void | now () |
| Set the GncDateTime to the date and time indicated in the computer's clock. | |
| operator time64 () const | |
| Cast the GncDateTime to a time64, seconds from the POSIX epoch. More... | |
| operator struct tm () const | |
| Cast the GncDateTime to a struct tm. More... | |
| long | offset () const |
| Obtain the UTC offset in seconds. More... | |
| struct tm | utc_tm () const |
| Obtain a struct tm representing the time in UTC. More... | |
| GncDate | date () const |
| Obtain the date from the time, as a GncDate, in the current timezone. More... | |
| bool | isnull (void) |
| Test if the GncDateTime has a member pointer. More... | |
| std::string | format (const char *format) const |
| Format the GncDateTime into a std::string. More... | |
| std::string | format_zulu (const char *format) const |
| Format the GncDateTime into a std::string in GMT. More... | |
| std::string | format_iso8601 () const |
| Format the GncDateTime into a gnucash-style iso8601 string in UTC. More... | |
Static Public Member Functions | |
| static std::string | timestamp () |
| Get an undelimited string representing the current date and time. More... | |
GnuCash DateTime class.
Represents local time in the current timezone. As with GncDate, the represented time is limited to the period between 1400 and 9999 CE.
Be careful when using times: A particular time is represented differently depending on the timezone, which can shift the displayed date. Accounting is generally not sensitive to the time of day, but is sensitive to the recorded day. Since GncDates are not timezone dependent they should be preferred for accounting entries.
Definition at line 70 of file gnc-datetime.hpp.
| GncDateTime::GncDateTime | ( | const time64 | time | ) |
Construct a GncDateTime in the current timezone representing the timestamp as seconds from the POSIX epoch (1970-01-01T00:00:00UTC).
| time | Seconds from the POSIX epoch. |
| std::invalid_argument | if the year is outside the constraints. |
Definition at line 788 of file gnc-datetime.cpp.
| GncDateTime::GncDateTime | ( | const struct tm | tm | ) |
Construct a GncDateTime in the current timezone representing the standard struct tm provided.
| tm | A C-standard struct tm representing the date and time. Note that the timezone and offset are ignored on those systems which include them in struct tm. |
| std::invalid_argument | if the year is outside the constraints. |
| GncDateTime::GncDateTime | ( | const GncDate & | date, |
| DayPart | part = DayPart::neutral |
||
| ) |
Construct a GncDateTime from a GncDate.
As a GncDate doesn't contain time information, the time will be set depending on the second parameter to start of day, neutral or end of day.
| date | A GncDate representing a date. |
| part | An optinoal DayPart indicating which time to use in the conversion. This can be "DayPart::start" for start of day (00:00 local time), "DayPart::neutral" for a neutral time (10:59 UTC, chosen to have the least chance of date changes when crossing timezone borders), "DayPart::end" for end of day (23:59 local time). If omitted part defaults to DayPart::neutral. Note the different timezone used for DayPart::neutral compared to the other two options! |
| std::invalid_argument | if the year is outside the constraints. |
Definition at line 798 of file gnc-datetime.cpp.
| GncDateTime::GncDateTime | ( | const std::string & | str | ) |
Construct a GncDateTime.
| str | A string representing the date and time in some recognizable format. Note that if a timezone is not specified the default is UTC, not the local one. |
| std::invalid_argument | if the year is outside the constraints. |
Definition at line 792 of file gnc-datetime.cpp.
| GncDate GncDateTime::date | ( | ) | const |
Obtain the date from the time, as a GncDate, in the current timezone.
Definition at line 830 of file gnc-datetime.cpp.
| std::string GncDateTime::format | ( | const char * | format | ) | const |
Format the GncDateTime into a std::string.
| format | A cstr describing the way the date and time are presented. Code letters preceded with % stand in for arguments; most are the same as described in strftime(3), but there are a few differences. Consult the boost::date_time documentation. |
Definition at line 836 of file gnc-datetime.cpp.
| std::string GncDateTime::format_iso8601 | ( | ) | const |
Format the GncDateTime into a gnucash-style iso8601 string in UTC.
Definition at line 848 of file gnc-datetime.cpp.
| std::string GncDateTime::format_zulu | ( | const char * | format | ) | const |
Format the GncDateTime into a std::string in GMT.
| format | A cstr describing the way the date and time are presented. Code letters preceded with % stand in for arguments; most are the same as described in strftime(3), but there are a few differences. Consult the boost::date_time documentation. |
Definition at line 842 of file gnc-datetime.cpp.
|
inline |
Test if the GncDateTime has a member pointer.
Testing only.
Definition at line 137 of file gnc-datetime.hpp.
| long GncDateTime::offset | ( | ) | const |
Obtain the UTC offset in seconds.
Definition at line 818 of file gnc-datetime.cpp.
|
explicit |
Cast the GncDateTime to a struct tm.
Timezone field isn't filled.
Definition at line 812 of file gnc-datetime.cpp.
|
explicit |
Cast the GncDateTime to a time64, seconds from the POSIX epoch.
Definition at line 807 of file gnc-datetime.cpp.
|
static |
Get an undelimited string representing the current date and time.
Definition at line 854 of file gnc-datetime.cpp.
| struct tm GncDateTime::utc_tm | ( | ) | const |
Obtain a struct tm representing the time in UTC.
Definition at line 824 of file gnc-datetime.cpp.
1.8.14