diff options
author | Jack Lloyd <[email protected]> | 2017-12-04 16:58:19 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-04 16:58:19 -0500 |
commit | f82ee841f719926e91eb4a5533c964821f08488d (patch) | |
tree | 21c5924b896caa716e9a690a6cc2463bbede82ea /src/lib/utils/calendar.h | |
parent | e5f39dd483a08accc8a12e8b322a48037c5b3bf4 (diff) |
Simplify date conversion by avoiding OS utilities
We have to rely on non-portable OS calls to convert UTC times,
and they are not available on many systems (including Solaris and MinGW).
But instead there is a simple algorithm due to Howard Hinnant that
does the same job. Woo.
Diffstat (limited to 'src/lib/utils/calendar.h')
-rw-r--r-- | src/lib/utils/calendar.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/lib/utils/calendar.h b/src/lib/utils/calendar.h index 665022599..3f6952524 100644 --- a/src/lib/utils/calendar.h +++ b/src/lib/utils/calendar.h @@ -21,25 +21,26 @@ namespace Botan { class BOTAN_PUBLIC_API(2,0) calendar_point { public: + /** The year */ - uint32_t year; + uint32_t get_year() const { return year; } /** The month, 1 through 12 for Jan to Dec */ - uint32_t month; + uint32_t get_month() const { return month; } /** The day of the month, 1 through 31 (or 28 or 30 based on month */ - uint32_t day; + uint32_t get_day() const { return day; } /** Hour in 24-hour form, 0 to 23 */ - uint32_t hour; + uint32_t get_hour() const { return hour; } /** Minutes in the hour, 0 to 60 */ - uint32_t minutes; + uint32_t get_minutes() const { return minutes; } /** Seconds in the minute, 0 to 60, but might be slightly - larger to deal with leap seconds on some systems + larger to deal with leap seconds on some systems */ - uint32_t seconds; + uint32_t get_seconds() const { return seconds; } /** * Initialize a calendar_point @@ -63,6 +64,17 @@ class BOTAN_PUBLIC_API(2,0) calendar_point * Formatting might change over time. Currently it is RFC339 'iso-date-time'. */ std::string to_string() const; + + /* + The member variables are public for historical reasons. Use the get_xxx() functions + defined above. These members will be made private in a future major release. + */ + uint32_t year; + uint32_t month; + uint32_t day; + uint32_t hour; + uint32_t minutes; + uint32_t seconds; }; /** |