diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-07-16 19:25:13 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-07-16 19:25:13 +0100 |
| commit | ec1097e8426461b854b38e7b14bc73995c365e0a (patch) | |
| tree | 19c8e41ff4061f48ba23524bc8e38f5398c1f21a /asdcplib/src/KM_tai.h | |
| parent | 7d48446b5efdf795df1ce22d6d9ed3ebe85d3381 (diff) | |
asdcplib 1.9.45
Diffstat (limited to 'asdcplib/src/KM_tai.h')
| -rw-r--r-- | asdcplib/src/KM_tai.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/asdcplib/src/KM_tai.h b/asdcplib/src/KM_tai.h new file mode 100644 index 00000000..a274e8db --- /dev/null +++ b/asdcplib/src/KM_tai.h @@ -0,0 +1,107 @@ +/* + +THIS IS A SUBSET OF THE FULL LIBTAI. CHANGES HAVE BEEN MADE TO SUIT +LIBKUMU STYLE AND TYPE CONVENTIONS. ALL BUGS BELONG TO JOHN HURST. +THE FOLLOWING IS FOR ATTRIBUTION, THANK YOU MR. BERNSTEIN FOR WRITING +AND DISTRIBUTING SUCH GREAT SOFTWARE: + +libtai 0.60, alpha. +19981013 +Copyright 1998 +D. J. Bernstein, djb@pobox.com +http://pobox.com/~djb/libtai.html + + +libtai is a library for storing and manipulating dates and times. + +libtai supports two time scales: (1) TAI64, covering a few hundred +billion years with 1-second precision; (2) TAI64NA, covering the same +period with 1-attosecond precision. Both scales are defined in terms of +TAI, the current international real time standard. + +libtai provides an internal format for TAI64, struct tai, designed for +fast time manipulations. The tai_pack() and tai_unpack() routines +convert between struct tai and a portable 8-byte TAI64 storage format. +libtai provides similar internal and external formats for TAI64NA. + +libtai provides struct caldate to store dates in year-month-day form. It +can convert struct caldate, under the Gregorian calendar, to a modified +Julian day number for easy date arithmetic. + +libtai provides struct caltime to store calendar dates and times along +with UTC offsets. It can convert from struct tai to struct caltime in +UTC, accounting for leap seconds, for accurate date and time display. It +can also convert back from struct caltime to struct tai for user input. +Its overall UTC-to-TAI conversion speed is 100x better than the usual +UNIX mktime() implementation. + +This version of libtai requires a UNIX system with gettimeofday(). It +will be easy to port to other operating systems with compilers +supporting 64-bit arithmetic. + +The libtai source code is in the public domain. + +*/ + + /*! \file KM_tai.h + \version $Id: KM_tai.h,v 1.5 2012/02/21 02:09:30 jhurst Exp $ + \brief portable time functions + */ + +#ifndef _KUMU_TAI_H_ +#define _KUMU_TAI_H_ + +#include <KM_platform.h> + +// +namespace Kumu +{ + namespace TAI + { + class caltime; + + // + struct tai + { + ui64_t x; + inline void add_seconds(i32_t s) { x += s; } + inline void add_minutes(i32_t m) { x += m * 60; } + inline void add_hours(i32_t h) { x += h * 3600; } + inline void add_days(i32_t d) { x += d * 86400; } + void now(); + + const tai& operator=(const caltime& rhs); + }; + + // + struct caldate + { + i32_t year; + i32_t month; + i32_t day; + }; + + // + class caltime + { + public: + caldate date; + i32_t hour; + i32_t minute; + i32_t second; + i32_t offset; + + const caltime& operator=(const tai& rhs); + }; + + + } // namespace TAI + +} // namespace Kumu + + +#endif // _KUMU_TAI_H_ + +// +// end KM_tai.h +// |
