MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / FormatRFC1123DateTime

Function FormatRFC1123DateTime

src/util/time.cpp:132–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132std::string FormatRFC1123DateTime(int64_t time)
133{
134 if (time < -62167219200 || 253402300799 < time) {
135 // 4-digit year, so only support years 0 to 9999
136 return "";
137 }
138 const std::chrono::sys_seconds secs{std::chrono::seconds{time}};
139 const auto days{std::chrono::floor<std::chrono::days>(secs)};
140 const auto w{days.time_since_epoch().count() % 7}; // will be in the range [-6, 6]
141 std::string_view weekday{weekdays.at(w >= 0 ? w : w + 7)};
142 const std::chrono::year_month_day ymd{days};
143 std::string_view month{months.at(unsigned{ymd.month()} - 1)};
144 const std::chrono::hh_mm_ss hms{secs - days};
145 // examples: Mon, 27 Jul 2009 12:28:53 GMT
146 // Fri, 31 May 2024 19:18:04 GMT
147 return strprintf("%03s, %02u %03s %04i %02i:%02i:%02i GMT", weekday, unsigned{ymd.day()}, month, signed{ymd.year()}, hms.hours().count(), hms.minutes().count(), hms.seconds().count());
148}
149
150struct timeval MillisToTimeval(int64_t nTimeout)
151{

Callers 2

WriteReplyMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 2

countMethod · 0.80
atMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68