43 typedef std::chrono::system_clock myclock;
44 static char YMDHMS[30];
45 static std::chrono::time_point<myclock,std::chrono::milliseconds> old_time;
47 const auto cur_time = time_point_cast<std::chrono::milliseconds>(myclock::now());
48 if (cur_time != old_time || tz != old_tz)
50#ifdef STD_FORMAT_CHRONO_
51 constexpr const std::string_view TIMESTAMP_FMT =
"{:%Y/%m/%d %H:%M:%S}";
55#if LOCALZONE_IS_TIMEZONE
56 auto ltm = tz->to_local(cur_time);
58 auto sys_t = std::chrono::system_clock::to_time_t(cur_time);
59 std::chrono::local_time<std::chrono::milliseconds> ltm(cur_time.time_since_epoch() + std::chrono::seconds(localtime(&sys_t)->tm_gmtoff));
61 tm_str = std::format(TIMESTAMP_FMT, ltm);
64 tm_str = std::format(TIMESTAMP_FMT, cur_time);
66 std::strcpy(YMDHMS, tm_str.c_str());
68 auto d = imaxdiv(cur_time.time_since_epoch().count(), 1000);
70 std::sprintf(YMDHMS + std::strftime(YMDHMS,
sizeof YMDHMS,
"%Y/%m/%d %H:%M:%S", std::localtime(&t)),
".%03" PRIdMAX, d.rem);