d-dima e98c636d75 Make "GMT+03:00" known timezone format 6 months ago
..
ut 1ac13c847b Library import 16 (#2433) 6 months ago
README.md 59aca5c518 Restoring authorship annotation for Ivan Komarov <Ivan.Komarov@dfyz.info>. Commit 2 of 2. 2 years ago
civil-inl.h b3c1a08629 Restoring authorship annotation for <gotmanov@yandex-team.ru>. Commit 2 of 2. 2 years ago
civil.cpp e98c636d75 Make "GMT+03:00" known timezone format 6 months ago
civil.h 1ac13c847b Library import 16 (#2433) 6 months ago
convert.cpp 1fe4b402b3 Restoring authorship annotation for <petrk@yandex-team.ru>. Commit 2 of 2. 2 years ago
convert.h 1fe4b402b3 Restoring authorship annotation for <petrk@yandex-team.ru>. Commit 2 of 2. 2 years ago
ya.make bf0f13dd39 add ymake export to ydb 1 year ago

README.md

A library for translating between absolute times (i.e., TInstant) and civil times (i.e., NDatetime::TSimpleTM) using the rules defined by a time zone (i.e., NDatetime::TTimeZone).

(the terms absolute and civil come from cctz#fundamental-concepts)

This is basically a wrapper around CCTZ with one important change: the time zone database is in Arcadia and is compiled with the library (which means your executable will end up ~2MB larger).

See contrib/libs/cctz/README if you think zone database is outdated.

Quick start:

#include <library/cpp/timezone_conversion/convert.h>

// NDatetime::{GetLocalTimeZone(),GetUtcTimeZone()} are also available.
NDatetime::TTimeZone msk = NDatetime::GetTimeZone("Europe/Moscow");
TInstant now = TInstant::Now();
NDatetime::TSimpleTM civil = NDatetime::ToCivilTime(now, msk);
Cout << "Local time in Moscow is " << civil.ToString() << Endl;
TInstant absolute = NDatetime::ToAbsoluteTime(civil, msk);
Cout << "The current UNIX time is " << absolute.Seconds() << Endl;