aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/calendar.h
diff options
context:
space:
mode:
authorlloyd <lloyd@randombit.net>2014-01-10 03:41:59 +0000
committerlloyd <lloyd@randombit.net>2014-01-10 03:41:59 +0000
commit6894dca64c04936d07048c0e8cbf7e25858548c3 (patch)
tree5d572bfde9fe667dab14e3f04b5285a85d8acd95 /src/lib/utils/calendar.h
parent9efa3be92442afb3d0b69890a36c7f122df18eda (diff)
Move lib into src
Diffstat (limited to 'src/lib/utils/calendar.h')
-rw-r--r--src/lib/utils/calendar.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/lib/utils/calendar.h b/src/lib/utils/calendar.h
new file mode 100644
index 000000000..d617cc9a0
--- /dev/null
+++ b/src/lib/utils/calendar.h
@@ -0,0 +1,63 @@
+/*
+* Calendar Functions
+* (C) 1999-2009 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_CALENDAR_H__
+#define BOTAN_CALENDAR_H__
+
+#include <botan/types.h>
+#include <chrono>
+
+namespace Botan {
+
+/**
+* Struct representing a particular date and time
+*/
+struct BOTAN_DLL calendar_point
+ {
+ /** The year */
+ u32bit year;
+
+ /** The month, 1 through 12 for Jan to Dec */
+ byte month;
+
+ /** The day of the month, 1 through 31 (or 28 or 30 based on month */
+ byte day;
+
+ /** Hour in 24-hour form, 0 to 23 */
+ byte hour;
+
+ /** Minutes in the hour, 0 to 60 */
+ byte minutes;
+
+ /** Seconds in the minute, 0 to 60, but might be slightly
+ larger to deal with leap seconds on some systems
+ */
+ byte seconds;
+
+ /**
+ * Initialize a calendar_point
+ * @param y the year
+ * @param mon the month
+ * @param d the day
+ * @param h the hour
+ * @param min the minute
+ * @param sec the second
+ */
+ calendar_point(u32bit y, byte mon, byte d, byte h, byte min, byte sec) :
+ year(y), month(mon), day(d), hour(h), minutes(min), seconds(sec) {}
+ };
+
+/*
+* @param time_point a time point from the system clock
+* @return calendar_point object representing this time point
+*/
+BOTAN_DLL calendar_point calendar_value(
+ const std::chrono::system_clock::time_point& time_point);
+
+}
+
+#endif