#pragma once #include "tag.hpp" namespace sprawl { namespace detail { namespace time { static constexpr int64_t EraFromYear(int64_t year) { return (year >= 0 ? year : year - 399) / 400; } static constexpr int64_t YearOfEra(int64_t year, int64_t era) { return year - era * 400; } static constexpr int64_t DayOfYear(int64_t day, int64_t month) { return (153 * (month + (month > 2 ? -3 : 9)) + 2) / 5 + day - 1; } static constexpr int64_t DayOfEra(int64_t yearOfEra, int64_t dayOfYear) { return yearOfEra * 365 + yearOfEra / 4 - yearOfEra / 100 + dayOfYear; } static constexpr int64_t DaysFromAdjustedCivil(int64_t year, int64_t month, int64_t day) { return EraFromYear(year) * 146097 + DayOfEra(YearOfEra(year, EraFromYear(year)), DayOfYear(day, month)) - 719468; } static constexpr int64_t DaysFromCivil(int64_t year, int64_t month, int64_t day) { return DaysFromAdjustedCivil(year - int64_t(month <= 2), month, day); } template struct numericMonth_; template<> struct numericMonth_ { static constexpr int64_t value = 1; }; template<> struct numericMonth_ { static constexpr int64_t value = 2; }; template<> struct numericMonth_ { static constexpr int64_t value = 3; }; template<> struct numericMonth_ { static constexpr int64_t value = 4; }; template<> struct numericMonth_ { static constexpr int64_t value = 5; }; template<> struct numericMonth_ { static constexpr int64_t value = 6; }; template<> struct numericMonth_ { static constexpr int64_t value = 7; }; template<> struct numericMonth_ { static constexpr int64_t value = 8; }; template<> struct numericMonth_ { static constexpr int64_t value = 9; }; template<> struct numericMonth_ { static constexpr int64_t value = 10; }; template<> struct numericMonth_ { static constexpr int64_t value = 11; }; template<> struct numericMonth_ { static constexpr int64_t value = 12; }; } template struct TagToDateTime; template struct TagToDateTime> { static constexpr int64_t value = t_SecondsTagType::template As() + t_MinutesTagType::template As() * 60 + t_HoursTagType::template As() * 60 * 60 + time::DaysFromCivil(t_YearTagType::template As(), time::numericMonth_::value, t_DayTagType::template As()) * 24 * 60 * 60; }; template struct TagToDateTime> { typedef sprawl::Tag TagType; static constexpr int64_t value = TagToDateTime::template Replace::template Split>::value; }; } typedef SPRAWL_TAG(__DATE__ " " __TIME__) COMPILE_DATE_TIME_TAG; constexpr int64_t compileTimestamp = detail::TagToDateTime::value; }