47 # define USE_OS_TZDB 0 50 #ifndef HAS_REMOTE_API 53 # define HAS_REMOTE_API 0 55 # define HAS_REMOTE_API 1 57 # else // HAS_REMOTE_API makes no since when using the OS timezone database 58 # define HAS_REMOTE_API 0 63 # pragma clang diagnostic push 64 # pragma clang diagnostic ignored "-Wconstant-logical-operand" 68 "USE_OS_TZDB and HAS_REMOTE_API can not be used together");
71 # pragma clang diagnostic pop 75 # define AUTO_DOWNLOAD HAS_REMOTE_API 79 "AUTO_DOWNLOAD can not be turned on without HAS_REMOTE_API");
82 # define USE_SHELL_API 1 87 # error "USE_OS_TZDB can not be used on Windows" 89 # ifndef MISSING_LEAP_SECONDS 91 # define MISSING_LEAP_SECONDS 1 93 # define MISSING_LEAP_SECONDS 0 97 # define MISSING_LEAP_SECONDS 0 100 #ifndef HAS_DEDUCTION_GUIDES 101 # if __cplusplus >= 201703 102 # define HAS_DEDUCTION_GUIDES 1 104 # define HAS_DEDUCTION_GUIDES 0 106 #endif // HAS_DEDUCTION_GUIDES 110 #if defined(_MSC_VER) && (_MSC_VER < 1900) 126 #include <type_traits> 131 # ifdef DATE_BUILD_DLL 132 # define DATE_API __declspec(dllexport) 133 # elif defined(DATE_USE_DLL) 134 # define DATE_API __declspec(dllimport) 139 # ifdef DATE_BUILD_DLL 140 # define DATE_API __attribute__ ((visibility ("default"))) 165 template<
class CharT,
class Traits>
166 std::basic_ostream<CharT, Traits>&
167 operator<<(std::basic_ostream<CharT, Traits>& os,
const sys_info& r)
169 os << r.
begin <<
'\n';
173 os << r.abbrev <<
'\n';
179 enum {
unique, nonexistent, ambiguous} result;
184 template<
class CharT,
class Traits>
185 std::basic_ostream<CharT, Traits>&
186 operator<<(std::basic_ostream<CharT, Traits>& os,
const local_info& r)
189 os <<
"nonexistent between\n";
191 os <<
"ambiguous between\n";
202 :
public std::runtime_error
205 template <
class Duration>
209 template <
class Duration>
215 template <
class Duration>
219 :
std::runtime_error(make_msg(tp, i))
223 template <
class Duration>
228 std::ostringstream os;
229 os << tp <<
" is in a gap between\n" 234 <<
" which are both equivalent to\n" 240 :
public std::runtime_error
243 template <
class Duration>
247 template <
class Duration>
253 template <
class Duration>
256 :
std::runtime_error(make_msg(tp, i))
260 template <
class Duration>
265 std::ostringstream os;
266 os << tp <<
" is ambiguous. It could be\n" 308 #else // !HAS_STRING_VIEW 324 #endif // !HAS_STRING_VIEW 327 template <
class Duration,
class TimeZonePtr>
330 template <
class Duration1,
class Duration2,
class TimeZonePtr>
335 template <
class Duration,
class TimeZonePtr = const time_zone*>
339 using duration =
typename std::common_type<Duration, std::chrono::seconds>::type;
346 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 347 template <
class T = TimeZonePtr,
352 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 353 template <
class T = TimeZonePtr,
360 template <
class T = TimeZonePtr,
361 class =
typename std::enable_if
363 std::is_constructible
369 explicit zoned_time(std::string_view name);
371 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 372 template <
class T = TimeZonePtr,
373 class =
typename std::enable_if
375 std::is_constructible
382 explicit zoned_time(
const std::string& name);
385 template <
class Duration2,
386 class =
typename std::enable_if
388 std::is_convertible<sys_time<Duration2>,
395 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 396 template <
class T = TimeZonePtr,
397 class =
typename std::enable_if
408 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 409 template <
class T = TimeZonePtr,
410 class =
typename std::enable_if
422 template <
class Duration2,
class TimeZonePtr2,
423 class =
typename std::enable_if
425 std::is_convertible<sys_time<Duration2>,
430 template <
class Duration2,
class TimeZonePtr2,
431 class =
typename std::enable_if
433 std::is_convertible<sys_time<Duration2>,
440 template <
class T = TimeZonePtr,
441 class =
typename std::enable_if
443 std::is_constructible
452 template <
class T = TimeZonePtr,
453 class =
typename std::enable_if
455 std::is_constructible
464 template <
class T = TimeZonePtr,
465 class =
typename std::enable_if
467 std::is_constructible
475 zoned_time(std::string_view name,
const local_time<Duration>& tp,
choose c);
477 template <
class T = TimeZonePtr,
478 class =
typename std::enable_if
480 std::is_constructible
487 zoned_time(std::string_view name,
const zoned_time& zt);
489 template <
class T = TimeZonePtr,
490 class =
typename std::enable_if
492 std::is_constructible
500 zoned_time(std::string_view name,
const zoned_time& zt,
choose);
502 #else // !HAS_STRING_VIEW 504 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 505 template <
class T = TimeZonePtr,
506 class =
typename std::enable_if
508 std::is_constructible
518 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 519 template <
class T = TimeZonePtr,
520 class =
typename std::enable_if
522 std::is_constructible
532 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 533 template <
class T = TimeZonePtr,
534 class =
typename std::enable_if
536 std::is_constructible
544 zoned_time(
const std::string& name,
const local_time<Duration>& tp);
546 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 547 template <
class T = TimeZonePtr,
548 class =
typename std::enable_if
550 std::is_constructible
558 zoned_time(
const char* name,
const local_time<Duration>& tp);
560 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 561 template <
class T = TimeZonePtr,
562 class =
typename std::enable_if
564 std::is_constructible
568 local_time<Duration>,
573 zoned_time(
const std::string& name,
const local_time<Duration>& tp,
choose c);
575 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 576 template <
class T = TimeZonePtr,
577 class =
typename std::enable_if
579 std::is_constructible
583 local_time<Duration>,
588 zoned_time(
const char* name,
const local_time<Duration>& tp,
choose c);
590 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 591 template <
class T = TimeZonePtr,
592 class =
typename std::enable_if
594 std::is_constructible
602 zoned_time(
const std::string& name,
const zoned_time& zt);
604 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 605 template <
class T = TimeZonePtr,
606 class =
typename std::enable_if
608 std::is_constructible
616 zoned_time(
const char* name,
const zoned_time& zt);
618 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 619 template <
class T = TimeZonePtr,
620 class =
typename std::enable_if
622 std::is_constructible
631 zoned_time(
const std::string& name,
const zoned_time& zt,
choose);
633 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 634 template <
class T = TimeZonePtr,
635 class =
typename std::enable_if
637 std::is_constructible
646 zoned_time(
const char* name,
const zoned_time& zt,
choose);
648 #endif // !HAS_STRING_VIEW 651 zoned_time& operator=(
const local_time<Duration>& ut);
656 TimeZonePtr get_time_zone()
const;
661 template <
class Duration1,
class Duration2,
class TimeZonePtr1>
667 template <
class CharT,
class Traits,
class Duration1,
class TimeZonePtr1>
669 std::basic_ostream<CharT, Traits>&
670 operator<<(std::basic_ostream<CharT, Traits>& os,
674 template <
class D,
class T>
friend class zoned_time;
679 #if HAS_DEDUCTION_GUIDES 684 template <
class Duration>
688 template <
class TimeZonePtr>
689 zoned_time(TimeZonePtr)
692 template <
class TimeZonePtr,
class Duration>
696 template <
class TimeZonePtr,
class Duration>
702 zoned_time(std::string_view)
705 template <
class Duration>
709 template <
class Duration>
713 #else // !HAS_STRING_VIEW 715 zoned_time(std::string)
718 template <
class Duration>
722 template <
class Duration>
726 #endif // !HAS_STRING_VIEW 728 template <
class Duration>
732 template <
class Duration>
736 template <
class Duration,
class TimeZonePtr,
class TimeZonePtr2>
740 template <
class Duration,
class TimeZonePtr,
class TimeZonePtr2>
744 #endif // HAS_DEDUCTION_GUIDES 746 template <
class Duration1,
class Duration2,
class TimeZonePtr>
752 return x.zone_ == y.zone_ && x.tp_ == y.tp_;
755 template <
class Duration1,
class Duration2,
class TimeZonePtr>
764 #if !defined(_MSC_VER) || (_MSC_VER >= 1900) 770 struct expanded_ttinfo;
771 # else // !USE_OS_TZDB 774 # endif // !USE_OS_TZDB 777 #endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) 784 std::vector<detail::transition> transitions_;
785 std::vector<detail::expanded_ttinfo> ttinfos_;
786 #else // !USE_OS_TZDB 787 std::vector<detail::zonelet> zonelets_;
788 #endif // !USE_OS_TZDB 789 std::unique_ptr<std::once_flag> adjusted_;
792 #if !defined(_MSC_VER) || (_MSC_VER >= 1900) 795 #else // defined(_MSC_VER) && (_MSC_VER < 1900) 798 #endif // defined(_MSC_VER) && (_MSC_VER < 1900) 802 const std::string& name()
const NOEXCEPT;
805 template <
class Duration>
local_info get_info(local_time<Duration> tp)
const;
807 template <
class Duration>
809 to_sys(local_time<Duration> tp)
const;
811 template <
class Duration>
813 to_sys(local_time<Duration> tp,
choose z)
const;
815 template <
class Duration>
825 #endif // !USE_OS_TZDB 831 template <
class Duration>
833 to_sys_impl(local_time<Duration> tp,
choose z, std::false_type)
const;
834 template <
class Duration>
836 to_sys_impl(local_time<Duration> tp,
choose, std::true_type)
const;
842 load_sys_info(std::vector<detail::transition>::const_iterator i)
const;
844 template <
class TimeType>
846 load_data(std::istream& inf, std::int32_t tzh_leapcnt, std::int32_t tzh_timecnt,
847 std::int32_t tzh_typecnt, std::int32_t tzh_charcnt);
848 #else // !USE_OS_TZDB 850 DATE_API void adjust_infos(
const std::vector<detail::Rule>& rules);
851 DATE_API void parse_info(std::istream& in);
852 #endif // !USE_OS_TZDB 855 #if defined(_MSC_VER) && (_MSC_VER < 1900) 859 : name_(std::move(src.name_))
860 , zonelets_(std::move(src.zonelets_))
861 , adjusted_(std::move(src.adjusted_))
868 name_ = std::move(src.name_);
869 zonelets_ = std::move(src.zonelets_);
870 adjusted_ = std::move(src.adjusted_);
874 #endif // defined(_MSC_VER) && (_MSC_VER < 1900) 883 template <
class Duration>
889 return get_info_impl(date::floor<seconds>(st));
892 template <
class Duration>
898 return get_info_impl(date::floor<seconds>(tp));
901 template <
class Duration>
906 return to_sys_impl(tp,
choose{}, std::true_type{});
909 template <
class Duration>
914 return to_sys_impl(tp, z, std::false_type{});
917 template <
class Duration>
923 auto i = get_info(tp);
924 return LT{(tp + i.offset).time_since_epoch()};
935 template <
class Duration>
937 time_zone::to_sys_impl(local_time<Duration> tp,
choose z, std::false_type)
const 939 using namespace date;
941 auto i = get_info(tp);
954 template <
class Duration>
956 time_zone::to_sys_impl(local_time<Duration> tp,
choose, std::true_type)
const 958 using namespace date;
960 auto i = get_info(tp);
978 const std::string&
name()
const {
return name_;}
979 const std::string&
target()
const {
return target_;}
981 friend bool operator==(
const link& x,
const link& y) {
return x.name_ == y.name_;}
982 friend bool operator< (
const link& x,
const link& y) {
return x.name_ < y.name_;}
992 #endif // !USE_OS_TZDB 994 #if !MISSING_LEAP_SECONDS 1010 friend bool operator==(
const leap& x,
const leap& y) {
return x.date_ == y.date_;}
1011 friend bool operator< (
const leap& x,
const leap& y) {
return x.date_ < y.date_;}
1013 template <
class Duration>
1018 return x.date_ == y;
1021 template <
class Duration>
1024 operator< (const leap& x, const sys_time<Duration>& y)
1029 template <
class Duration>
1032 operator< (const sys_time<Duration>& x,
const leap& y)
1045 template <
class Duration>
1053 template <
class Duration>
1061 template <
class Duration>
1069 template <
class Duration>
1077 template <
class Duration>
1085 template <
class Duration>
1088 operator<=(const leap& x, const sys_time<Duration>& y)
1093 template <
class Duration>
1096 operator<=(const sys_time<Duration>& x,
const leap& y)
1101 template <
class Duration>
1109 template <
class Duration>
1117 #endif // !MISSING_LEAP_SECONDS 1141 struct timezone_mapping
1143 timezone_mapping(
const char* other,
const char* territory,
const char* type)
1144 : other(other), territory(territory), type(type)
1147 timezone_mapping() =
default;
1149 std::string territory;
1159 std::string version =
"unknown";
1164 #if !MISSING_LEAP_SECONDS 1171 std::vector<detail::timezone_mapping> mappings;
1176 #if !defined(_MSC_VER) || (_MSC_VER >= 1900) 1179 #else // defined(_MSC_VER) && (_MSC_VER < 1900) 1181 : version(
std::move(src.version))
1182 , zones(
std::move(src.zones))
1183 , links(
std::move(src.links))
1184 , leaps(
std::move(src.leaps))
1185 , rules(
std::move(src.rules))
1186 , mappings(
std::move(src.mappings))
1191 version = std::move(src.version);
1192 zones = std::move(src.zones);
1193 links = std::move(src.links);
1194 leaps = std::move(src.leaps);
1195 rules = std::move(src.rules);
1196 mappings = std::move(src.mappings);
1199 #endif // defined(_MSC_VER) && (_MSC_VER < 1900) 1218 std::atomic<tzdb*> head_{
nullptr};
1240 void push_front(
tzdb*
tzdb) noexcept;
1266 {
return x.p_ == y.p_;}
1311 #endif // !USE_OS_TZDB 1334 template <
class Po
inter>
1345 template <
class Duration,
class TimeZonePtr>
1346 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1347 template <
class T,
class>
1354 template <
class Duration,
class TimeZonePtr>
1355 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1356 template <
class T,
class>
1364 template <
class Duration,
class TimeZonePtr>
1367 : zone_(
std::move(z))
1372 template <
class Duration,
class TimeZonePtr>
1373 template <
class,
class>
1379 #else // !HAS_STRING_VIEW 1381 template <
class Duration,
class TimeZonePtr>
1382 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1383 template <
class T,
class>
1387 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name))
1390 #endif // !HAS_STRING_VIEW 1392 template <
class Duration,
class TimeZonePtr>
1393 template <
class Duration2,
class>
1400 template <
class Duration,
class TimeZonePtr>
1403 : zone_(
std::move(z))
1407 template <
class Duration,
class TimeZonePtr>
1408 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1409 template <
class T,
class>
1413 : zone_(
std::move(z))
1414 , tp_(zone_->to_sys(t))
1417 template <
class Duration,
class TimeZonePtr>
1418 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1419 template <
class T,
class>
1424 : zone_(
std::move(z))
1425 , tp_(zone_->to_sys(t, c))
1428 template <
class Duration,
class TimeZonePtr>
1429 template <
class Duration2,
class TimeZonePtr2,
class>
1433 : zone_(
std::move(z))
1437 template <
class Duration,
class TimeZonePtr>
1438 template <
class Duration2,
class TimeZonePtr2,
class>
1442 : zoned_time(
std::move(z), zt)
1447 template <
class Duration,
class TimeZonePtr>
1448 template <
class,
class>
1455 template <
class Duration,
class TimeZonePtr>
1456 template <
class,
class>
1459 const local_time<Duration>& t)
1463 template <
class Duration,
class TimeZonePtr>
1464 template <
class,
class>
1467 const local_time<Duration>& t,
choose c)
1471 template <
class Duration,
class TimeZonePtr>
1472 template <
class,
class>
1478 template <
class Duration,
class TimeZonePtr>
1479 template <
class,
class>
1482 const zoned_time& zt,
choose c)
1486 #else // !HAS_STRING_VIEW 1488 template <
class Duration,
class TimeZonePtr>
1489 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1490 template <
class T,
class>
1495 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), st)
1498 template <
class Duration,
class TimeZonePtr>
1499 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1500 template <
class T,
class>
1505 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), st)
1508 template <
class Duration,
class TimeZonePtr>
1509 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1510 template <
class T,
class>
1514 const local_time<Duration>& t)
1515 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), t)
1518 template <
class Duration,
class TimeZonePtr>
1519 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1520 template <
class T,
class>
1524 const local_time<Duration>& t)
1525 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), t)
1528 template <
class Duration,
class TimeZonePtr>
1529 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1530 template <
class T,
class>
1534 const local_time<Duration>& t,
choose c)
1535 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), t, c)
1538 template <
class Duration,
class TimeZonePtr>
1539 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1540 template <
class T,
class>
1544 const local_time<Duration>& t,
choose c)
1545 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), t, c)
1548 template <
class Duration,
class TimeZonePtr>
1549 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1550 template <
class T,
class>
1554 const zoned_time& zt)
1555 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), zt)
1558 template <
class Duration,
class TimeZonePtr>
1559 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1560 template <
class T,
class>
1564 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), zt)
1567 template <
class Duration,
class TimeZonePtr>
1568 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1569 template <
class T,
class>
1573 const zoned_time& zt,
choose c)
1574 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), zt, c)
1577 template <
class Duration,
class TimeZonePtr>
1578 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1579 template <
class T,
class>
1583 const zoned_time& zt,
choose c)
1584 : zoned_time(
zoned_traits<TimeZonePtr>::locate_zone(name), zt, c)
1587 #endif // HAS_STRING_VIEW 1589 template <
class Duration,
class TimeZonePtr>
1598 template <
class Duration,
class TimeZonePtr>
1603 tp_ = zone_->to_sys(ut);
1607 template <
class Duration,
class TimeZonePtr>
1614 template <
class Duration,
class TimeZonePtr>
1621 template <
class Duration,
class TimeZonePtr>
1629 template <
class Duration,
class TimeZonePtr>
1634 return zone_->to_local(tp_);
1637 template <
class Duration,
class TimeZonePtr>
1645 template <
class Duration,
class TimeZonePtr>
1650 return zone_->get_info(tp_);
1662 template <
class Duration>
1670 template <
class TimeZonePtr
1671 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1672 ,
class =
typename std::enable_if
1698 template <
class Duration,
class TimeZonePtr
1699 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1700 ,
class =
typename std::enable_if
1702 std::is_class<typename std::decay<decltype(*std::declval<TimeZonePtr&>())>::type>{}
1710 return zoned_time<typename std::common_type<Duration, std::chrono::seconds>::type,
1711 TimeZonePtr>(std::move(zone), tp);
1714 template <
class Duration,
class TimeZonePtr
1715 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1716 ,
class =
typename std::enable_if
1718 std::is_class<typename std::decay<decltype(*std::declval<TimeZonePtr&>())>::type>{}
1723 zoned_time<typename std::common_type<Duration, std::chrono::seconds>::type, TimeZonePtr>
1726 return zoned_time<typename std::common_type<Duration, std::chrono::seconds>::type,
1727 TimeZonePtr>(std::move(zone), tp, c);
1730 template <
class Duration>
1732 zoned_time<typename std::common_type<Duration, std::chrono::seconds>::type>
1733 make_zoned(
const std::string& name,
const local_time<Duration>& tp)
1735 return zoned_time<
typename std::common_type<Duration,
1736 std::chrono::seconds>::type>(name, tp);
1739 template <
class Duration>
1741 zoned_time<typename std::common_type<Duration, std::chrono::seconds>::type>
1744 return zoned_time<
typename std::common_type<Duration,
1745 std::chrono::seconds>::type>(name, tp, c);
1748 template <
class Duration,
class TimeZonePtr>
1756 template <
class Duration,
class TimeZonePtr>
1764 template <
class Duration,
class TimeZonePtr>
1772 template <
class Duration,
class TimeZonePtr>
1780 template <
class Duration,
class TimeZonePtr
1781 #if !defined(_MSC_VER) || (_MSC_VER > 1900) 1782 ,
class =
typename std::enable_if
1784 std::is_class<typename std::decay<decltype(*std::declval<TimeZonePtr&>())>::type>{}
1789 zoned_time<typename std::common_type<Duration, std::chrono::seconds>::type, TimeZonePtr>
1792 return zoned_time<typename std::common_type<Duration, std::chrono::seconds>::type,
1793 TimeZonePtr>(std::move(zone), st);
1796 template <
class Duration>
1798 zoned_time<typename std::common_type<Duration, std::chrono::seconds>::type>
1801 return zoned_time<
typename std::common_type<Duration,
1802 std::chrono::seconds>::type>(name, st);
1805 template <
class CharT,
class Traits,
class Duration,
class TimeZonePtr>
1806 std::basic_ostream<CharT, Traits>&
1807 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
1814 auto const info =
tz->get_info(st);
1815 return to_stream(os, fmt, LT{(st+info.offset).time_since_epoch()},
1816 &info.abbrev, &info.offset);
1819 template <
class CharT,
class Traits,
class Duration,
class TimeZonePtr>
1821 std::basic_ostream<CharT, Traits>&
1824 const CharT fmt[] = {
'%',
'F',
' ',
'%',
'T',
' ',
'%',
'Z', CharT{}};
1828 #if !MISSING_LEAP_SECONDS 1841 template<
typename Duration>
1843 std::chrono::time_point<std::chrono::system_clock, typename std::common_type<Duration, std::chrono::seconds>::type>
1844 to_sys(
const std::chrono::time_point<utc_clock, Duration>&);
1846 template<
typename Duration>
1848 std::chrono::time_point<utc_clock, typename std::common_type<Duration, std::chrono::seconds>::type>
1849 from_sys(
const std::chrono::time_point<std::chrono::system_clock, Duration>&);
1852 template <
class Duration>
1853 using utc_time = std::chrono::time_point<utc_clock, Duration>;
1857 template <
class Duration>
1862 using duration =
typename std::common_type<Duration, seconds>::type;
1864 auto const lt = std::upper_bound(leaps.begin(), leaps.end(), st);
1871 template <
class Duration>
1872 std::pair<bool, std::chrono::seconds>
1875 using namespace date;
1877 using duration =
typename std::common_type<Duration, seconds>::type;
1880 auto const lt = std::upper_bound(leaps.begin(), leaps.end(), tp);
1881 auto ds = seconds{lt-leaps.begin()};
1884 if (lt > leaps.begin())
1888 if (tp >= lt[-1].
date() - seconds{1})
1897 template <
class Duration>
1902 using duration =
typename std::common_type<Duration, seconds>::type;
1906 tp = floor<seconds>(tp) + seconds{1} -
duration{1};
1915 return from_sys(system_clock::now());
1918 template <
class CharT,
class Traits,
class Duration>
1919 std::basic_ostream<CharT, Traits>&
1920 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
1923 using namespace std;
1925 using CT =
typename common_type<Duration, seconds>::type;
1926 const string abbrev(
"UTC");
1929 auto tp =
sys_time<CT>{t.time_since_epoch() - ls.second};
1930 auto const sd = floor<days>(tp);
1933 time.seconds() += seconds{ls.first};
1935 return to_stream(os, fmt, fds, &abbrev, &offset);
1938 template <
class CharT,
class Traits,
class Duration>
1939 std::basic_ostream<CharT, Traits>&
1942 const CharT fmt[] = {
'%',
'F',
' ',
'%',
'T', CharT{}};
1946 template <
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
1947 std::basic_istream<CharT, Traits>&
1950 std::chrono::minutes* offset =
nullptr)
1952 using namespace std;
1954 using CT =
typename common_type<Duration, seconds>::type;
1955 minutes offset_local{};
1956 auto offptr = offset ? offset : &offset_local;
1960 is.setstate(ios::failbit);
1963 bool is_60_sec = fds.tod.seconds() == seconds{60};
1965 fds.tod.seconds() -= seconds{1};
1969 if (is_60_sec !=
is_leap_second(tmp).first || !fds.tod.in_conventional_range())
1971 is.setstate(ios::failbit);
1974 tp = time_point_cast<Duration>(tmp);
1988 static const bool is_steady =
false;
1992 template<
typename Duration>
1994 std::chrono::time_point<utc_clock, typename std::common_type<Duration, std::chrono::seconds>::type>
1995 to_utc(
const std::chrono::time_point<tai_clock, Duration>&)
NOEXCEPT;
1997 template<
typename Duration>
1999 std::chrono::time_point<tai_clock, typename std::common_type<Duration, std::chrono::seconds>::type>
2000 from_utc(
const std::chrono::time_point<utc_clock, Duration>&)
NOEXCEPT;
2003 template <
class Duration>
2004 using tai_time = std::chrono::time_point<tai_clock, Duration>;
2008 template <
class Duration>
2014 using duration =
typename std::common_type<Duration, seconds>::type;
2019 template <
class Duration>
2025 using duration =
typename std::common_type<Duration, seconds>::type;
2038 template <
class CharT,
class Traits,
class Duration>
2039 std::basic_ostream<CharT, Traits>&
2040 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
2043 using namespace std;
2045 using CT =
typename common_type<Duration, seconds>::type;
2046 const string abbrev(
"TAI");
2050 auto const sd = floor<days>(tp);
2054 return to_stream(os, fmt, fds, &abbrev, &offset);
2057 template <
class CharT,
class Traits,
class Duration>
2058 std::basic_ostream<CharT, Traits>&
2061 const CharT fmt[] = {
'%',
'F',
' ',
'%',
'T', CharT{}};
2065 template <
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
2066 std::basic_istream<CharT, Traits>&
2069 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
2070 std::chrono::minutes* offset =
nullptr)
2072 using namespace std;
2074 using CT =
typename common_type<Duration, seconds>::type;
2075 minutes offset_local{};
2076 auto offptr = offset ? offset : &offset_local;
2079 if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
2080 is.setstate(ios::failbit);
2085 *offptr + fds.tod.to_duration()).time_since_epoch())};
2098 static const bool is_steady =
false;
2102 template<
typename Duration>
2104 std::chrono::time_point<utc_clock, typename std::common_type<Duration, std::chrono::seconds>::type>
2105 to_utc(
const std::chrono::time_point<gps_clock, Duration>&)
NOEXCEPT;
2107 template<
typename Duration>
2109 std::chrono::time_point<gps_clock, typename std::common_type<Duration, std::chrono::seconds>::type>
2110 from_utc(
const std::chrono::time_point<utc_clock, Duration>&)
NOEXCEPT;
2114 template <
class Duration>
2115 using gps_time = std::chrono::time_point<gps_clock, Duration>;
2119 template <
class Duration>
2125 using duration =
typename std::common_type<Duration, seconds>::type;
2130 template <
class Duration>
2136 using duration =
typename std::common_type<Duration, seconds>::type;
2149 template <
class CharT,
class Traits,
class Duration>
2150 std::basic_ostream<CharT, Traits>&
2151 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
2154 using namespace std;
2156 using CT =
typename common_type<Duration, seconds>::type;
2157 const string abbrev(
"GPS");
2161 auto const sd = floor<days>(tp);
2165 return to_stream(os, fmt, fds, &abbrev, &offset);
2168 template <
class CharT,
class Traits,
class Duration>
2169 std::basic_ostream<CharT, Traits>&
2172 const CharT fmt[] = {
'%',
'F',
' ',
'%',
'T', CharT{}};
2176 template <
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
2177 std::basic_istream<CharT, Traits>&
2180 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
2181 std::chrono::minutes* offset =
nullptr)
2183 using namespace std;
2185 using CT =
typename common_type<Duration, seconds>::type;
2186 minutes offset_local{};
2187 auto offptr = offset ? offset : &offset_local;
2190 if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
2191 is.setstate(ios::failbit);
2196 *offptr + fds.tod.to_duration()).time_since_epoch())};
2202 template <
class DstClock,
class SrcClock>
2209 template <
class Duration>
2220 template <
class Duration>
2231 template <
class Duration>
2242 template <
class Duration>
2250 template <
class Clock>
2253 template <
class Duration>
2254 std::chrono::time_point<Clock, Duration>
2255 operator()(
const std::chrono::time_point<Clock, Duration>& tp)
const 2261 namespace ctc_detail
2264 template <
class Clock,
class Duration>
2268 using std::chrono::system_clock;
2272 template <
class Clock,
class TimePo
int>
2279 "time point with appropariate clock shall be returned");
2284 template <
class Clock,
class Duration,
class =
void>
2288 template <
class Clock,
class Duration>
2292 decltype(Clock::to_sys(declval<time_point<Clock, Duration> const&>()), void())
2297 decltype(Clock::to_sys(declval<time_point<Clock, Duration> const&>()))
2302 template <
class Clock,
class Duration,
class =
void>
2306 template <
class Clock,
class Duration>
2310 decltype(Clock::from_sys(declval<time_point<system_clock, Duration> const&>()),
2316 decltype(Clock::from_sys(declval<time_point<system_clock, Duration> const&>()))
2321 template <
class Clock,
class Duration,
class =
void>
2325 template <
class Clock,
class Duration>
2329 decltype(Clock::to_utc(declval<time_point<Clock, Duration> const&>()), void())
2334 decltype(Clock::to_utc(declval<time_point<Clock, Duration> const&>()))>
2338 template <
class Clock,
class Duration,
class =
void>
2342 template <
class Clock,
class Duration>
2346 decltype(Clock::from_utc(declval<time_point<utc_clock, Duration> const&>()),
2352 decltype(Clock::from_utc(declval<time_point<utc_clock, Duration> const&>()))
2358 template <
class SrcClock>
2361 template <
class Duration>
2363 operator()(
const std::chrono::time_point<SrcClock, Duration>& tp)
const 2365 return SrcClock::to_sys(tp);
2369 template <
class DstClock>
2372 template <
class Duration>
2376 return DstClock::from_sys(st);
2380 template <
class SrcClock>
2383 template <
class Duration>
2385 operator()(
const std::chrono::time_point<SrcClock, Duration>& tp)
const 2387 return SrcClock::to_utc(tp);
2391 template <
class DstClock>
2394 template <
class Duration>
2398 return DstClock::from_utc(ut);
2402 namespace clock_cast_detail
2405 template <
class Clock,
class Duration>
2407 using std::chrono::system_clock;
2409 template <
class DstClock,
class SrcClock,
class Duration>
2418 template <
class DstClock,
class SrcClock,
class Duration>
2421 -> decltype(conv_clock<DstClock>(t))
2423 return conv_clock<DstClock>(t);
2427 template <
class DstClock,
class SrcClock,
class Duration>
2430 -> decltype(conv_clock<DstClock>(conv_clock<system_clock>(t)))
2432 return conv_clock<DstClock>(conv_clock<system_clock>(t));
2436 template <
class DstClock,
class SrcClock,
class Duration>
2440 conv_clock<DstClock>(conv_clock<utc_clock>(t)))
2442 return conv_clock<DstClock>(conv_clock<utc_clock>(t));
2446 template <
class DstClock,
class SrcClock,
class Duration>
2449 -> decltype(conv_clock<DstClock>(conv_clock<utc_clock>(conv_clock<system_clock>(t))))
2451 return conv_clock<DstClock>(conv_clock<utc_clock>(conv_clock<system_clock>(t)));
2455 template <
class DstClock,
class SrcClock,
class Duration>
2459 conv_clock<DstClock>(conv_clock<system_clock>(conv_clock<utc_clock>(t))))
2461 return conv_clock<DstClock>(conv_clock<system_clock>(conv_clock<utc_clock>(t)));
2466 template <
class DstClock,
class SrcClock,
class Duration>
2468 clock_cast(
const std::chrono::time_point<SrcClock, Duration>& tp)
2469 -> decltype(clock_cast_detail::cc_impl<DstClock>(tp, &tp))
2471 return clock_cast_detail::cc_impl<DstClock>(tp, &tp);
2476 template <
class Duration>
2484 template <
class Duration>
2492 template <
class Duration>
2501 template <
class Duration>
2509 template <
class Duration>
2517 template <
class Duration>
2526 template <
class Duration>
2534 template <
class Duration>
2542 template <
class Duration>
2551 template <
class Duration>
2559 template <
class Duration>
2567 template <
class Duration>
2575 #endif // !MISSING_LEAP_SECONDS
ctc_detail::return_to_utc< SrcClock, Duration >::type operator()(const std::chrono::time_point< SrcClock, Duration > &tp) const
Definition: tz.h:2385
CONSTDATA date::weekday sun
Definition: date.h:1849
CONSTCD11 bool operator==(const day &x, const day &y) NOEXCEPT
Definition: date.h:1274
ambiguous_local_time(local_time< Duration > tp, const local_info &i)
Definition: tz.h:255
time_zone & operator=(time_zone &&)=default
std::chrono::time_point< gps_clock, Duration > gps_time
Definition: tz.h:2115
#define DATE_API
Definition: tz.h:142
static const time_zone * locate_zone(const std::string &name)
Definition: tz.h:312
#define NOEXCEPT
Definition: date.h:124
gps_time< typename std::common_type< Duration, std::chrono::seconds >::type > to_gps_time(const sys_time< Duration > &t)
Definition: tz.h:2554
time_zone(time_zone &&)=default
sys_time< std::chrono::seconds > sys_seconds
Definition: date.h:164
static std::chrono::time_point< utc_clock, typename std::common_type< Duration, std::chrono::seconds >::type > to_utc(const std::chrono::time_point< gps_clock, Duration > &) NOEXCEPT
bool remote_download(const std::string &version)
Definition: tz.cpp:3248
zoned_time< std::chrono::seconds > zoned_seconds
Definition: tz.h:677
friend bool operator!=(const const_iterator &x, const const_iterator &y) noexcept
Definition: tz.h:1270
std::ptrdiff_t difference_type
Definition: tz.h:1255
static const time_zone * default_zone()
Definition: tz.h:294
duration::rep rep
Definition: tz.h:1834
duration::period period
Definition: tz.h:1986
local_time< typename std::common_type< Duration, std::chrono::seconds >::type > to_local(sys_time< Duration > tp) const
Definition: tz.h:920
ctc_detail::return_to_sys< SrcClock, Duration >::type operator()(const std::chrono::time_point< SrcClock, Duration > &tp) const
Definition: tz.h:2363
reference operator*() const noexcept
Definition: tz.h:1257
std::chrono::time_point< gps_clock > time_point
Definition: tz.h:2097
std::basic_istream< CharT, Traits > & from_stream(std::basic_istream< CharT, Traits > &is, const CharT *fmt, fields< Duration > &fds, std::basic_string< CharT, Traits, Alloc > *abbrev=nullptr, std::chrono::minutes *offset=nullptr)
Definition: date.h:5951
GeneratorWrapper< T > value(T &&value)
Definition: catch.hpp:4005
std::chrono::time_point< Clock, Duration > time_point
Definition: tz.h:2265
auto clock_cast(const std::chrono::time_point< SrcClock, Duration > &tp) -> decltype(clock_cast_detail::cc_impl< DstClock >(tp, &tp))
Definition: tz.h:2468
T * to_raw_pointer(T *p) noexcept
Definition: tz.h:1329
const_iterator operator++(int) noexcept
Definition: tz.h:1261
std::vector< detail::Rule > rules
Definition: tz.h:1168
sys_seconds begin
Definition: tz.h:158
sys_info get_info(sys_time< Duration > st) const
Definition: tz.h:886
ctc_detail::return_from_sys< DstClock, Duration >::type operator()(const sys_time< Duration > &st) const
Definition: tz.h:2374
sys_time< days > sys_days
Definition: date.h:163
std::chrono::minutes save
Definition: tz.h:161
sys_seconds end
Definition: tz.h:159
sys_seconds date() const
Definition: tz.h:1008
CONSTCD11 bool operator>(const day &x, const day &y) NOEXCEPT
Definition: date.h:1298
friend bool operator==(const const_iterator &x, const const_iterator &y) noexcept
Definition: tz.h:1265
sys_time< typename std::common_type< Duration, std::chrono::seconds >::type > to_sys(local_time< Duration > tp) const
Definition: tz.h:904
utc_time< typename std::common_type< Duration, std::chrono::seconds >::type > to_utc_time(const sys_time< Duration > &t)
Definition: tz.h:2504
std::pair< bool, std::chrono::seconds > is_leap_second(date::utc_time< Duration > const &ut)
Definition: tz.h:1873
const std::string & name() const NOEXCEPT
Definition: tz.h:878
tzdb & front() noexcept
Definition: tz.h:1226
local_time< duration > get_local_time() const
Definition: tz.h:1632
const tzdb & get_tzdb()
Definition: tz.cpp:3479
std::chrono::time_point< utc_clock > time_point
Definition: tz.h:1836
const_iterator end() const noexcept
Definition: tz.h:1285
sys_info second
Definition: tz.h:181
const_iterator & operator++() noexcept
Definition: tz.h:1260
friend bool operator==(const link &x, const link &y)
Definition: tz.h:981
tai_time< typename std::common_type< Duration, std::chrono::seconds >::type > to_tai_time(const sys_time< Duration > &t)
Definition: tz.h:2529
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const day &d)
Definition: date.h:1355
sys_info first
Definition: tz.h:180
std::vector< leap > leaps
Definition: tz.h:1165
zoned_time< std::chrono::seconds > make_zoned()
Definition: tz.h:1657
std::vector< link > links
Definition: tz.h:1162
utc_time< Duration > operator()(const utc_time< Duration > &ut) const
Definition: tz.h:2222
static time_point now()
Definition: tz.h:1912
std::chrono::system_clock::duration duration
Definition: tz.h:1984
std::string abbrev
Definition: tz.h:162
nonexistent_local_time(local_time< Duration > tp, const local_info &i)
Definition: tz.h:217
const time_zone * current_zone()
Definition: tz.cpp:3783
tzdb * next
Definition: tz.h:1173
tz
Definition: tz_private.h:45
CONSTDATA date::month jan
Definition: date.h:1836
CONSTCD11 time_of_day< std::chrono::duration< Rep, Period > > make_time(const std::chrono::duration< Rep, Period > &d)
Definition: date.h:4264
static time_point now()
Definition: tz.h:2143
#define CONSTDATA
Definition: date.h:121
pointer operator->() const noexcept
Definition: tz.h:1258
gps_time< std::chrono::seconds > gps_seconds
Definition: tz.h:2117
static std::chrono::time_point< utc_clock, typename std::common_type< Duration, std::chrono::seconds >::type > to_utc(const std::chrono::time_point< tai_clock, Duration > &) NOEXCEPT
const_iterator begin() const noexcept
Definition: tz.h:1278
static std::chrono::time_point< gps_clock, typename std::common_type< Duration, std::chrono::seconds >::type > from_utc(const std::chrono::time_point< utc_clock, Duration > &) NOEXCEPT
std::basic_ostream< CharT, Traits > & to_stream(std::basic_ostream< CharT, Traits > &os, const CharT *fmt, const fields< Duration > &fds, const std::string *abbrev=nullptr, const std::chrono::seconds *offset_sec=nullptr)
Definition: date.h:4598
enum date::local_info::@3 result
CONSTCD11 bool operator>=(const day &x, const day &y) NOEXCEPT
Definition: date.h:1314
const time_zone * locate_zone(const std::string &tz_name)
Definition: tz.cpp:3532
zoned_time()
Definition: tz.h:1350
std::chrono::time_point< Clock, Duration > time_point
Definition: tz.h:2406
decltype(Clock::to_sys(declval< time_point< Clock, Duration > const &>())) type
Definition: tz.h:2276
std::chrono::time_point< std::chrono::system_clock, Duration > sys_time
Definition: date.h:161
ctc_detail::return_from_utc< DstClock, Duration >::type operator()(const utc_time< Duration > &ut) const
Definition: tz.h:2396
CONSTCD11 bool operator!=(const day &x, const day &y) NOEXCEPT
Definition: date.h:1282
std::chrono::time_point< tai_clock, Duration > tai_time
Definition: tz.h:2004
TimeZonePtr get_time_zone() const
Definition: tz.h:1624
friend bool operator==(const leap &x, const leap &y)
Definition: tz.h:1010
duration::rep rep
Definition: tz.h:1985
int add(int code, T value)
Definition: HashCoder.h:34
tzdb_list & get_tzdb_list()
Definition: tz.cpp:444
typename std::common_type< Duration, std::chrono::seconds >::type duration
Definition: tz.h:339
duration::period period
Definition: tz.h:1835
std::string remote_version()
Definition: tz.cpp:2852
bool remote_install(const std::string &version)
Definition: tz.cpp:3280
auto conv_clock(const time_point< SrcClock, Duration > &t) -> decltype(std::declval< clock_time_conversion< DstClock, SrcClock >>()(t))
Definition: tz.h:2411
Definition: tz_private.h:220
static time_point now()
Definition: tz.h:2032
local_time< std::chrono::seconds > local_seconds
Definition: date.h:171
const std::string & name() const
Definition: tz.h:978
static std::chrono::time_point< tai_clock, typename std::common_type< Duration, std::chrono::seconds >::type > from_utc(const std::chrono::time_point< utc_clock, Duration > &) NOEXCEPT
auto cc_impl(const time_point< SrcClock, Duration > &t,...) -> decltype(conv_clock< DstClock >(conv_clock< utc_clock >(conv_clock< system_clock >(t))))
Definition: tz.h:2448
sys_time< duration > get_sys_time() const
Definition: tz.h:1640
sys_time< typename std::common_type< Duration, std::chrono::seconds >::type > to_sys_time(const utc_time< Duration > &t)
Definition: tz.h:2479
sys_time< Duration > operator()(const sys_time< Duration > &st) const
Definition: tz.h:2211
tai_time< std::chrono::seconds > tai_seconds
Definition: tz.h:2006
static std::chrono::time_point< utc_clock, typename std::common_type< Duration, std::chrono::seconds >::type > from_sys(const std::chrono::time_point< std::chrono::system_clock, Duration > &)
auto to_raw_pointer(Pointer p) noexcept -> decltype(detail::to_raw_pointer(p.operator->()))
Definition: tz.h:1337
friend bool operator==(const leap &x, const sys_time< Duration > &y)
Definition: tz.h:1016
zoned_time & operator=(const sys_time< Duration > &st)
Definition: tz.h:1592
static std::chrono::time_point< std::chrono::system_clock, typename std::common_type< Duration, std::chrono::seconds >::type > to_sys(const std::chrono::time_point< utc_clock, Duration > &)
duration::rep rep
Definition: tz.h:2095
choose
Definition: tz.h:149
std::chrono::system_clock::duration duration
Definition: tz.h:1833
time_point< system_clock, typename decltype(Clock::to_sys(declval< time_point< Clock, Duration > const &>())) ::duration > clock_time_point
Definition: tz.h:2275
utc_time< std::chrono::seconds > utc_seconds
Definition: tz.h:1855
const_iterator cend() const noexcept
Definition: tz.h:1299
const_iterator cbegin() const noexcept
Definition: tz.h:1292
const tzdb & reload_tzdb()
Definition: tz.cpp:3465
const std::string & target() const
Definition: tz.h:979
std::chrono::system_clock::duration duration
Definition: tz.h:2094
std::chrono::time_point< Clock, Duration > operator()(const std::chrono::time_point< Clock, Duration > &tp) const
Definition: tz.h:2255
#define USE_OS_TZDB
Definition: tz.h:47
#define AUTO_DOWNLOAD
Definition: tz.h:75
std::chrono::time_point< tai_clock > time_point
Definition: tz.h:1987
CONSTCD11 bool operator<(const day &x, const day &y) NOEXCEPT
Definition: date.h:1290
duration::period period
Definition: tz.h:2096
const tzdb & front() const noexcept
Definition: tz.h:1225
Definition: tz_private.h:148
std::chrono::time_point< local_t, Duration > local_time
Definition: date.h:169
std::vector< time_zone > zones
Definition: tz.h:1160
std::forward_iterator_tag iterator_category
Definition: tz.h:1251
#define HAS_REMOTE_API
Definition: tz.h:55
sys_time< typename std::common_type< Duration, std::chrono::seconds >::type > operator()(const utc_time< Duration > &ut) const
Definition: tz.h:2244
sys_info get_info() const
Definition: tz.h:1648
std::chrono::time_point< utc_clock, Duration > utc_time
Definition: tz.h:1853
void set_install(const std::string &s)
Definition: tz.cpp:287
std::chrono::seconds offset
Definition: tz.h:160
static const time_zone * locate_zone(const char *name)
Definition: tz.h:319
utc_time< typename std::common_type< Duration, std::chrono::seconds >::type > operator()(const sys_time< Duration > &st) const
Definition: tz.h:2233
CONSTCD11 bool operator<=(const day &x, const day &y) NOEXCEPT
Definition: date.h:1306