Botan 2.19.2
Crypto and TLS for C&
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
16namespace Botan {
17
18/**
19* Struct representing a particular date and time
20*/
22 {
23 public:
24
25 /** The year */
26 uint32_t get_year() const { return year; }
27
28 /** The month, 1 through 12 for Jan to Dec */
29 uint32_t get_month() const { return month; }
30
31 /** The day of the month, 1 through 31 (or 28 or 30 based on month */
32 uint32_t get_day() const { return day; }
33
34 /** Hour in 24-hour form, 0 to 23 */
35 uint32_t get_hour() const { return hour; }
36
37 /** Minutes in the hour, 0 to 60 */
38 uint32_t get_minutes() const { return minutes; }
39
40 /** Seconds in the minute, 0 to 60, but might be slightly
41 larger to deal with leap seconds on some systems
42 */
43 uint32_t get_seconds() const { return seconds; }
44
45 /**
46 * Initialize a calendar_point
47 * @param y the year
48 * @param mon the month
49 * @param d the day
50 * @param h the hour
51 * @param min the minute
52 * @param sec the second
53 */
54 calendar_point(uint32_t y, uint32_t mon, uint32_t d, uint32_t h, uint32_t min, uint32_t sec) :
55 year(y), month(mon), day(d), hour(h), minutes(min), seconds(sec) {}
56
57 /**
58 * Returns an STL timepoint object
59 */
60 std::chrono::system_clock::time_point to_std_timepoint() const;
61
62 /**
63 * Returns a human readable string of the struct's components.
64 * Formatting might change over time. Currently it is RFC339 'iso-date-time'.
65 */
66 std::string to_string() const;
67
68 BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES:
69 /*
70 The member variables are public for historical reasons. Use the get_xxx() functions
71 defined above. These members will be made private in a future major release.
72 */
73 uint32_t year;
74 uint32_t month;
75 uint32_t day;
76 uint32_t hour;
77 uint32_t minutes;
78 uint32_t seconds;
79 };
80
81/**
82* Convert a time_point to a calendar_point
83* @param time_point a time point from the system clock
84* @return calendar_point object representing this time point
85*/
87 const std::chrono::system_clock::time_point& time_point);
88
89}
90
91#endif
uint32_t get_minutes() const
Definition: calendar.h:38
uint32_t get_month() const
Definition: calendar.h:29
calendar_point(uint32_t y, uint32_t mon, uint32_t d, uint32_t h, uint32_t min, uint32_t sec)
Definition: calendar.h:54
uint32_t get_seconds() const
Definition: calendar.h:43
uint32_t get_hour() const
Definition: calendar.h:35
uint32_t get_year() const
Definition: calendar.h:26
uint32_t get_day() const
Definition: calendar.h:32
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:13
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition: exceptn.cpp:11
calendar_point calendar_value(const std::chrono::system_clock::time_point &time_point)
Definition: calendar.cpp:111
Definition: bigint.h:1143