Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
constants.hpp
Go to the documentation of this file.
1#pragma once
6#ifndef _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
7#define _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
8
9#include <cstdint>
10#include <limits>
11
12namespace time_shield {
13
14 // Nanoseconds and microseconds
15 constexpr int64_t NS_PER_US = 1000;
16 constexpr int64_t NS_PER_MS = 1000000;
17 constexpr int64_t NS_PER_SEC = 1000000000;
18
19 // Microseconds and milliseconds
20 constexpr int64_t US_PER_SEC = 1000000;
21 constexpr int64_t MS_PER_SEC = 1000;
22 constexpr int64_t MS_PER_MIN = 60000;
23 constexpr int64_t MS_PER_HALF_HOUR = 1800000;
24 constexpr int64_t MS_PER_HOUR = 3600000;
25 constexpr int64_t MS_PER_DAY = 86400000;
26
27 // Seconds
28 constexpr int64_t SEC_PER_MIN = 60;
29 constexpr int64_t SEC_PER_HALF_HOUR = 1800;
30 constexpr int64_t SEC_PER_HOUR = 3600;
31 constexpr int64_t SEC_PER_DAY = 86400;
32 constexpr int64_t SEC_PER_YEAR = 31536000;
33 constexpr int64_t AVG_SEC_PER_YEAR = 31557600;
34 constexpr int64_t SEC_PER_LEAP_YEAR = 31622400;
35 constexpr int64_t SEC_PER_4_YEARS = 126230400;
36 constexpr int64_t SEC_PER_FIRST_100_YEARS = 3155760000;
37 constexpr int64_t SEC_PER_100_YEARS = 3155673600;
38 constexpr int64_t SEC_PER_400_YEARS = 12622780800;
39 constexpr int64_t MAX_SEC_PER_DAY = 86399;
40
41 // Minutes
42 constexpr int64_t MIN_PER_HOUR = 60;
43 constexpr int64_t MIN_PER_DAY = 1440;
44 constexpr int64_t MIN_PER_WEEK = 10080;
45 constexpr int64_t MIN_PER_MONTH = 40320;
46 constexpr int64_t MAX_MOON_MIN = 42523;
47
48 // Hours and days
49 constexpr int64_t HOURS_PER_DAY = 24;
50 constexpr int64_t DAYS_PER_WEEK = 7;
51 constexpr int64_t DAYS_PER_LEAP_YEAR = 366;
52 constexpr int64_t DAYS_PER_YEAR = 365;
53 constexpr int64_t DAYS_PER_4_YEARS = 1461;
54
55 // Months and years
56 const int64_t MONTHS_PER_YEAR = 12;
57 const int64_t MAX_DAYS_PER_MONTH = 31;
58 const int64_t LEAP_YEAR_PER_100_YEAR = 24;
59 const int64_t LEAP_YEAR_PER_400_YEAR = 97;
60
61 // Epoch and maximum values
62 constexpr int64_t UNIX_EPOCH = 1970;
63 constexpr int64_t OLE_EPOCH = 25569;
64 constexpr int64_t MAX_YEAR = 292277022000LL;
65 constexpr int64_t MIN_YEAR = -2967369602200LL;
66 constexpr int64_t ERROR_YEAR = 9223372036854770000LL;
67 constexpr int64_t MAX_TIMESTAMP = 9223371890843040000LL;
68 constexpr int64_t ERROR_TIMESTAMP = 9223372036854770000LL;
69 constexpr double MAX_OADATE = std::numeric_limits<double>::max();
70 constexpr double AVG_DAYS_PER_YEAR = 365.25;
71
72}; // namespace time_shield
73
74#endif // _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
Main namespace for the Time Shield library.
Definition constants.hpp:12
const int64_t MONTHS_PER_YEAR
Months per year.
Definition constants.hpp:56
constexpr int64_t SEC_PER_LEAP_YEAR
Seconds per leap year (366 days)
Definition constants.hpp:34
constexpr int64_t HOURS_PER_DAY
Hours per day.
Definition constants.hpp:49
constexpr int64_t OLE_EPOCH
OLE automation date since UNIX epoch.
Definition constants.hpp:63
constexpr int64_t SEC_PER_FIRST_100_YEARS
Seconds per first 100 years.
Definition constants.hpp:36
constexpr int64_t MIN_YEAR
Minimum representable year.
Definition constants.hpp:65
constexpr int64_t MIN_PER_WEEK
Minutes per week.
Definition constants.hpp:44
constexpr int64_t MIN_PER_HOUR
Minutes per hour.
Definition constants.hpp:42
constexpr int64_t MIN_PER_DAY
Minutes per day.
Definition constants.hpp:43
constexpr int64_t DAYS_PER_LEAP_YEAR
Days per leap year.
Definition constants.hpp:51
const int64_t LEAP_YEAR_PER_400_YEAR
Leap years per 400 years.
Definition constants.hpp:59
constexpr int64_t NS_PER_US
Nanoseconds per microsecond.
Definition constants.hpp:15
constexpr int64_t MS_PER_DAY
Milliseconds per day.
Definition constants.hpp:25
constexpr int64_t MAX_TIMESTAMP
Maximum timestamp value.
Definition constants.hpp:67
constexpr int64_t MS_PER_HOUR
Milliseconds per hour.
Definition constants.hpp:24
constexpr int64_t DAYS_PER_YEAR
Days per year.
Definition constants.hpp:52
constexpr int64_t MAX_SEC_PER_DAY
Maximum seconds per day.
Definition constants.hpp:39
constexpr int64_t MIN_PER_MONTH
Minutes per month (28 days)
Definition constants.hpp:45
constexpr int64_t SEC_PER_DAY
Seconds per day.
Definition constants.hpp:31
constexpr int64_t MS_PER_SEC
Milliseconds per second.
Definition constants.hpp:21
constexpr int64_t SEC_PER_MIN
Seconds per minute.
Definition constants.hpp:28
constexpr int64_t MS_PER_HALF_HOUR
Milliseconds per half hour.
Definition constants.hpp:23
constexpr int64_t SEC_PER_HOUR
Seconds per hour.
Definition constants.hpp:30
constexpr int64_t DAYS_PER_4_YEARS
Days per 4 years.
Definition constants.hpp:53
constexpr int64_t ERROR_TIMESTAMP
Error timestamp value.
Definition constants.hpp:68
constexpr int64_t DAYS_PER_WEEK
Days per week.
Definition constants.hpp:50
constexpr int64_t NS_PER_MS
Nanoseconds per millisecond.
Definition constants.hpp:16
constexpr int64_t SEC_PER_4_YEARS
Seconds per 4 years.
Definition constants.hpp:35
constexpr int64_t SEC_PER_100_YEARS
Seconds per 100 years.
Definition constants.hpp:37
constexpr double MAX_OADATE
Maximum OLE automation date.
Definition constants.hpp:69
constexpr int64_t SEC_PER_400_YEARS
Seconds per 400 years.
Definition constants.hpp:38
constexpr int64_t MAX_YEAR
Maximum representable year.
Definition constants.hpp:64
constexpr int64_t AVG_SEC_PER_YEAR
Average seconds per year (365.25 days)
Definition constants.hpp:33
constexpr int64_t MS_PER_MIN
Milliseconds per minute.
Definition constants.hpp:22
constexpr double AVG_DAYS_PER_YEAR
Average days per year.
Definition constants.hpp:70
constexpr int64_t NS_PER_SEC
Nanoseconds per second.
Definition constants.hpp:17
const int64_t LEAP_YEAR_PER_100_YEAR
Leap years per 100 years.
Definition constants.hpp:58
constexpr int64_t UNIX_EPOCH
Start year of UNIX time.
Definition constants.hpp:62
constexpr int64_t SEC_PER_HALF_HOUR
Seconds per half hour.
Definition constants.hpp:29
constexpr int64_t SEC_PER_YEAR
Seconds per year (365 days)
Definition constants.hpp:32
const int64_t MAX_DAYS_PER_MONTH
Maximum days per month.
Definition constants.hpp:57
constexpr int64_t ERROR_YEAR
Error year value.
Definition constants.hpp:66
constexpr int64_t MAX_MOON_MIN
Maximum lunar minutes.
Definition constants.hpp:46
constexpr int64_t US_PER_SEC
Microseconds per second.
Definition constants.hpp:20