Add call to parent constructor.
[asdcplib-cth.git] / src / KM_tai.h
1 /*
2
3 THIS IS A SUBSET OF THE FULL LIBTAI. CHANGES HAVE BEEN MADE TO SUIT
4 LIBKUMU STYLE AND TYPE CONVENTIONS. ALL BUGS BELONG TO JOHN HURST.
5 THE FOLLOWING IS FOR ATTRIBUTION, THANK YOU MR. BERNSTEIN FOR WRITING
6 AND DISTRIBUTING SUCH GREAT SOFTWARE:
7
8 libtai 0.60, alpha.
9 19981013
10 Copyright 1998
11 D. J. Bernstein, djb@pobox.com
12 http://pobox.com/~djb/libtai.html
13
14
15 libtai is a library for storing and manipulating dates and times.
16
17 libtai supports two time scales: (1) TAI64, covering a few hundred
18 billion years with 1-second precision; (2) TAI64NA, covering the same
19 period with 1-attosecond precision. Both scales are defined in terms of
20 TAI, the current international real time standard.
21
22 libtai provides an internal format for TAI64, struct tai, designed for
23 fast time manipulations. The tai_pack() and tai_unpack() routines
24 convert between struct tai and a portable 8-byte TAI64 storage format.
25 libtai provides similar internal and external formats for TAI64NA.
26
27 libtai provides struct caldate to store dates in year-month-day form. It
28 can convert struct caldate, under the Gregorian calendar, to a modified
29 Julian day number for easy date arithmetic.
30
31 libtai provides struct caltime to store calendar dates and times along
32 with UTC offsets. It can convert from struct tai to struct caltime in
33 UTC, accounting for leap seconds, for accurate date and time display. It
34 can also convert back from struct caltime to struct tai for user input.
35 Its overall UTC-to-TAI conversion speed is 100x better than the usual
36 UNIX mktime() implementation.
37
38 This version of libtai requires a UNIX system with gettimeofday(). It
39 will be easy to port to other operating systems with compilers
40 supporting 64-bit arithmetic.
41
42 The libtai source code is in the public domain.
43
44 */
45
46   /*! \file    KM_tai.h
47     \version $Id: KM_tai.h,v 1.5 2012/02/21 02:09:30 jhurst Exp $
48     \brief   portable time functions
49   */
50
51 #ifndef _KUMU_TAI_H_
52 #define _KUMU_TAI_H_
53
54 #include <KM_platform.h>
55
56 //
57 namespace Kumu
58 {
59   namespace TAI
60   {
61     class caltime;
62
63     //
64     struct tai
65     {
66       ui64_t x;
67       inline void add_seconds(i32_t s)  { x += s; }
68       inline void add_minutes(i32_t m) { x += m * 60; }
69       inline void add_hours(i32_t h) { x += h * 3600; }
70       inline void add_days(i32_t d) { x += d * 86400; }
71       void now();
72
73       const tai& operator=(const caltime& rhs);
74     };
75     
76     //
77     struct caldate
78     {
79       i32_t year;
80       i32_t month;
81       i32_t day;
82     };
83
84     //
85     class caltime
86     {
87     public:
88       caldate date;
89       i32_t hour;
90       i32_t minute;
91       i32_t second;
92       i32_t offset;
93
94       const caltime& operator=(const tai& rhs);
95     };
96
97
98   } // namespace TAI
99
100 } // namespace Kumu
101
102
103 #endif // _KUMU_TAI_H_
104
105 //
106 // end KM_tai.h
107 //