Added an clock_time_conversion trait, that should be specialized with SourceClock and DestClock respectively and provide an function that convert time_point in SourceClock to equivalent time_point in DestClock. This function has following specializations: 1) <sys_clock, utc_clock> - convert sys_time to utc_time 2) <utc_clock, sys_clock> - convert utc_time to sys_time 3) <Clock, sys_clock> - calls Clock::to_sys if it returns sys_time 4) <Clock, utc_clock> - calls Clock::to_utc if it returns utc_time 5) <sys_clock, Clock> - calls Clock::from_sys if it returns time_point<Clock> 5) <utc_clock, Clock> - calls Clock::from_utc if it returns time_point<Clock> Implemented an clock_cast<DestClock>(time_point<SourceClock, Dur> st), that works as follow: 1) If DestClock is same as SourceClock, returns std 2) Otherwise, if clock_conversion<SourceClock, DestClock> available, uses it 3) Otherwise, if tries using clock_conversion<SourceClock, CommClock> and clock_conversion<CommClock, DestClock> for CommClock being utc_time or sys_time 4) Otherwise, tries using clock_conversion<SourceClock, utc_clock> and clock_conversion<sys_clock, DestinationClock> or reversed (firstly convert to sys_clock, then to utc_clock) to convert.
This is actually several separate C++11/C++14 libraries:
-
"date.h"is a header-only library which builds upon<chrono>. It adds some newdurationtypes, and newtime_pointtypes. It also adds "field" types such asyear_month_daywhich is a struct{year, month, day}. And it provides convenient means to convert between the "field" types and thetime_pointtypes. -
"tz.h"/"tz.cpp"are a timezone library built on top of the"date.h"library. This timezone library is a complete parser of the IANA timezone database. It provides for an easy way to access all of the data in this database, using the types from"date.h"and<chrono>. The IANA database also includes data on leap seconds, and this library provides utilities to compute with that information as well. -
"iso_week.h"is a header-only library built on top of the"date.h"library which implements the ISO week date calendar.- Documentation: http://howardhinnant.github.io/date/iso_week.html
-
"julian.h"is a header-only library built on top of the"date.h"library which implements a proleptic Julian calendar which is fully interoperable with everything above.- Documentation: http://howardhinnant.github.io/date/julian.html
-
"islamic.h"is a header-only library built on top of the"date.h"library which implements a proleptic Islamic calendar which is fully interoperable with everything above.- Documentation: http://howardhinnant.github.io/date/islamic.html
"date.h" and "tz.h" are now being proposed for standardization:
- Current proposal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0355r4.html
- Draft revision: http://howardhinnant.github.io/date/d0355r5.html
- Status: The proposal was approved by LEWG and forwarded to LWG with the recommendation of targeting C++20 at the Albuquerque, NM meeting in Nov. 2017.
List of projects using this library:
- www.safe.com
- www.webtoolkit.eu/wt
If you would like your project (or product) on this list, just let me know.