A date and time library for use with C++11 and C++14 -- Howard Hinnant

This paper fully documents a date and time library for use with C++11 and C++14.

Library documentation:

by Howard Hinnant

From the article:

Implementation

This entire library is implemented in a single header: date.h and is open source (with generous open source terms — not generous enough? Contact me, I'm flexible).

It uses the algorithms from chrono-Compatible Low-Level Date Algorithms. If you want detailed explanations of the algorithms, go there.

It performs best with C++14, which has vastly improved constexpr rules. However, the library will auto-adopt to C++11, sacrificing several constexpr declarations. In C++11, this will effectively transfer some computations that should be done at compile-time to run-time. Porting to C++98/03 has not been attempted.

Overview

This library builds date and date/time support on top of the <chrono> library. However it does not support timezones nor leap seconds. A separate library is provided, built on top of this one, for timezone and leap second support. Thus you only pay for such support if you need it.

Add a Comment

Comments are closed.

Comments (3)

0 0

Ivan Le Lann said on Jul 23, 2015 01:10 AM:

Might be a silly question but :

Why is the library hard plugged on std::chrono::system_clock ?
Couldn't a monotonic clock make sense for some applications ?
0 0

Kristian Ivarsson said on Jul 23, 2015 03:52 AM:

When will the world learn to stick to ISO-8601 (extended) formats (with accurate accuracy/precition) only wink
0 0

Howard Hinnant said on Jul 27, 2015 10:07 AM:

std::chrono::steady_clock has no relationship to any calendar. It is like a stopwatch. You can time stuff with it, but you can't use it to get the current time.