Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

calendar.h
Go to the documentation of this file.
1 /*
2 * Calendar Functions
3 * (C) 1999-2009,2015 Jack Lloyd
4 * (C) 2015 Simon Warta (Kullo GmbH)
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8
9 #ifndef BOTAN_CALENDAR_H__
10 #define BOTAN_CALENDAR_H__
11
12 #include <botan/types.h>
13 #include <chrono>
14 #include <string>
15
16 namespace Botan {
17
18 /**
19 * Struct representing a particular date and time
20 */
21 struct BOTAN_DLL calendar_point
22 {
23 /** The year */
24 uint32_t year;
25
26 /** The month, 1 through 12 for Jan to Dec */
27 uint32_t month;
28
29 /** The day of the month, 1 through 31 (or 28 or 30 based on month */
30 uint32_t day;
31
32 /** Hour in 24-hour form, 0 to 23 */
33 uint32_t hour;
34
35 /** Minutes in the hour, 0 to 60 */
36 uint32_t minutes;
37
38 /** Seconds in the minute, 0 to 60, but might be slightly
39 larger to deal with leap seconds on some systems
40 */
41 uint32_t seconds;
42
43 /**
44 * Initialize a calendar_point
45 * @param y the year
46 * @param mon the month
47 * @param d the day
48 * @param h the hour
49 * @param min the minute
50 * @param sec the second
51 */
52 calendar_point(uint32_t y, uint32_t mon, uint32_t d, uint32_t h, uint32_t min, uint32_t sec) :
53 year(y), month(mon), day(d), hour(h), minutes(min), seconds(sec) {}
54
55 /**
56 * Returns an STL timepoint object
57 */
58 std::chrono::system_clock::time_point to_std_timepoint() const;
59
60 /**
61 * Returns a human readable string of the struct's components.
62 * Formatting might change over time. Currently it is RFC339 'iso-date-time'.
63 */
64 std::string to_string() const;
65 };
66
67 /**
68 * Convert a time_point to a calendar_point
69 * @param time_point a time point from the system clock
70 * @return calendar_point object representing this time point
71 */
72 BOTAN_DLL calendar_point calendar_value(
73 const std::chrono::system_clock::time_point& time_point);
74
75 }
76
77 #endif
Botan::calendar_point::year
uint32_t year
Definition: calendar.h:24
Botan::calendar_point::day
uint32_t day
Definition: calendar.h:30
Botan::calendar_point::hour
uint32_t hour
Definition: calendar.h:33
Botan::calendar_point
Definition: calendar.h:21
Botan
Definition: alg_id.cpp:13
Botan::calendar_point::calendar_point
calendar_point(uint32_t y, uint32_t mon, uint32_t d, uint32_t h, uint32_t min, uint32_t sec)
Definition: calendar.h:52
Botan::calendar_point::month
uint32_t month
Definition: calendar.h:27
Botan::to_string
std::string to_string(const secure_vector< uint8_t > &bytes)
Definition: stl_util.h:25
Botan::CT::min
T min(T a, T b)
Definition: ct_utils.h:180
Botan::calendar_point::minutes
uint32_t minutes
Definition: calendar.h:36
Botan::calendar_point::seconds
uint32_t seconds
Definition: calendar.h:41
Botan::calendar_value
calendar_point calendar_value(const std::chrono::system_clock::time_point &time_point)
Definition: calendar.cpp:177