CppCon 2015: Greg Miller “Time Programming Fundamentals'

preview_player
Показать описание


"Time zones are logical and easy to use." -- No one ever

Time programming is notoriously difficult and error prone. Attempts at handling daylight-saving time, for example, often yield baffling code, which of course is explained by a similarly misguided comment. Programmer confusion can spread virally throughout the codebase when these misconceptions find their way into library interfaces.

The problem is not that dates and times are fundamentally complicated (though they are). The problem is the lack of a simplified mental model with library support. This would give programmers the concepts and vocabulary necessary to reason about and discuss these concepts, and the ability to express this reasoning in simple C++ terms.

In this talk I will show how date and time programming evolved into what it is today. I will present a greatly simplified mental model that applies to all programming languages. I will show clear examples using an open source C++ library that implements these simplified concepts. And I will present practical tips for proper time hygiene that should be used by everyone immediately.

I design and implement C++ core libraries at Google. I work on Google's core strings libraries, as well as a Google's Time and Time Zone libraries.


*-----*
*--*
*-----*
Рекомендации по теме
Комментарии
Автор

I never thought I would see a graph of time over time.

demetriuspsf
Автор

The open-sourced code is available at GitHub/google/cctz and it works on Linux and Mac OS X.

devjgm
Автор

Great talk, and looking forward to using and recommending this library! This is very reminiscent of functions in the highly refined Java 8 java.time API, also in Noda Time in .Net, and Joda Time prior to that. Great to see C++ getting into this!

MattJohnson
Автор

How does this compare to C++20 chrono?

aniketbisht
Автор

The mistake is converting civil time to absolute for any reason other than determining and setting the current civil timezone for an account/display, which would by its nature be able to be explicitly flagged as pre or post time shift. All time should be tracked, calculated, and recorded in absolute time and only converted to civil for trivial display purposes. The absurdity of local government proclamations that attempt to control such a thing as time, should be openly trivialized and flat ignored where possible.
For computer records purposes that absolute time should be a flat count of seconds TAI (not utc) and UTC calculated from TAI if needed. This avoids time zone shifts and leap seconds corrupting ordinal event records, like financial transactions, where A occurring before B is far more important than the actual precision.

mytech
Автор

thank you for this great talk. Python? : )

victornoagbodji
visit shbcf.ru