aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/calendar.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/utils/calendar.h')
-rw-r--r--src/lib/utils/calendar.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/lib/utils/calendar.h b/src/lib/utils/calendar.h
index 4efff0edc..0c87e62dd 100644
--- a/src/lib/utils/calendar.h
+++ b/src/lib/utils/calendar.h
@@ -1,6 +1,7 @@
/*
* Calendar Functions
* (C) 1999-2009 Jack Lloyd
+* (C) 2015 Simon Warta (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
@@ -10,6 +11,7 @@
#include <botan/types.h>
#include <chrono>
+#include <string>
namespace Botan {
@@ -22,21 +24,21 @@ struct BOTAN_DLL calendar_point
u32bit year;
/** The month, 1 through 12 for Jan to Dec */
- byte month;
+ u32bit month;
/** The day of the month, 1 through 31 (or 28 or 30 based on month */
- byte day;
+ u32bit day;
/** Hour in 24-hour form, 0 to 23 */
- byte hour;
+ u32bit hour;
/** Minutes in the hour, 0 to 60 */
- byte minutes;
+ u32bit minutes;
/** Seconds in the minute, 0 to 60, but might be slightly
larger to deal with leap seconds on some systems
*/
- byte seconds;
+ u32bit seconds;
/**
* Initialize a calendar_point
@@ -47,11 +49,23 @@ struct BOTAN_DLL calendar_point
* @param min the minute
* @param sec the second
*/
- calendar_point(u32bit y, byte mon, byte d, byte h, byte min, byte sec) :
+ calendar_point(u32bit y, u32bit mon, u32bit d, u32bit h, u32bit min, u32bit sec) :
year(y), month(mon), day(d), hour(h), minutes(min), seconds(sec) {}
+
+ /**
+ * Returns an STL timepoint object
+ */
+ std::chrono::system_clock::time_point to_std_timepoint();
+
+ /**
+ * Returns a human readable string of the struct's components.
+ * Formatting might change over time. Currently it is RFC339 'iso-date-time'.
+ */
+ std::string to_string() const;
};
-/*
+/**
+* Convert a time_point to a calendar_point
* @param time_point a time point from the system clock
* @return calendar_point object representing this time point
*/