-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
36 lines (29 loc) · 1.33 KB
/
test.cpp
File metadata and controls
36 lines (29 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iomanip>
#include <iostream>
#include "clock.h"
// A clock that provides the current Julian day
// Julian time is in units of days, and has an epoch
// of noon on 1 January, 4713 BCE
using JulianClock = EpochClock<
std::chrono::duration<long double, std::ratio<86400> > >;
template <>
const typename JulianClock::duration JulianClock::epoch{2440587.5};
// A clock that provides the current Gregorian time
// Gregorian time in units of 100ns. The Gregorian calendar
// has an epoch of midnight on 15 October, 1582 CE
using GregorianClock = EpochClock<
std::chrono::duration<uint64_t, std::ratio<1, 10000000> > >;
template <>
const typename GregorianClock::duration GregorianClock::epoch{0x1b21dd213814000};
int main() {
auto current_julian_time = JulianClock::now();
std::cout << "Current Julian time = " << std::fixed
<< current_julian_time.time_since_epoch().count() << std::endl;
auto current_greg_time = GregorianClock::now();
std::cout << "Current Gregorian time = "
<< current_greg_time.time_since_epoch().count() << std::endl;
GregorianClock::time_point time{GregorianClock::duration(137000856413280000ULL)};
std::cout << "Converting " << time.time_since_epoch().count() << " to system time = "
<< GregorianClock::to_time_t(time) << std::endl;
return 0;
}