1#include <iostream>
2#include <cstring>
3
4#include <common/DateLUT.h>
5
6
7static std::string toString(time_t Value)
8{
9 struct tm tm;
10 char buf[96];
11
12 localtime_r(&Value, &tm);
13 snprintf(buf, sizeof(buf), "%04d-%02d-%02d %02d:%02d:%02d",
14 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
15
16 return buf;
17}
18
19static time_t orderedIdentifierToDate(unsigned value)
20{
21 struct tm tm;
22
23 memset(&tm, 0, sizeof(tm));
24
25 tm.tm_year = value / 10000 - 1900;
26 tm.tm_mon = (value % 10000) / 100 - 1;
27 tm.tm_mday = value % 100;
28 tm.tm_isdst = -1;
29
30 return mktime(&tm);
31}
32
33
34void loop(time_t begin, time_t end, int step)
35{
36 const auto & date_lut = DateLUT::instance();
37
38 for (time_t t = begin; t < end; t += step)
39 std::cout << toString(t)
40 << ", " << toString(date_lut.toTime(t))
41 << ", " << date_lut.toHour(t)
42 << std::endl;
43}
44
45
46int main(int argc, char ** argv)
47{
48 loop(orderedIdentifierToDate(20101031), orderedIdentifierToDate(20101101), 15 * 60);
49 loop(orderedIdentifierToDate(20100328), orderedIdentifierToDate(20100330), 15 * 60);
50 loop(orderedIdentifierToDate(20141020), orderedIdentifierToDate(20141106), 15 * 60);
51
52 return 0;
53}
54