MCPcopy Create free account
hub / github.com/catboost/catboost / WritePrintableLocalTimeToStream

Function WritePrintableLocalTimeToStream

util/datetime/base.cpp:100–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99 template <bool PrintUpToSeconds, bool iso>
100 void WritePrintableLocalTimeToStream(IOutputStream& os, const ::NPrivate::TPrintableLocalTime<PrintUpToSeconds, iso>& timeToPrint) {
101 const TInstant& momentToPrint = timeToPrint.MomentToPrint;
102 struct tm localTime;
103 momentToPrint.LocalTime(&localTime);
104 WriteTmToStream(os, localTime);
105 if (!PrintUpToSeconds) {
106 WriteMicroSecondsToStream(os, momentToPrint.MicroSecondsOfSecond());
107 }
108#ifndef _win_
109 i64 utcOffsetInMinutes = localTime.tm_gmtoff / 60;
110#else
111 TIME_ZONE_INFORMATION tz;
112 if (GetTimeZoneInformation(&tz) == TIME_ZONE_ID_INVALID) {
113 ythrow TSystemError() << "Failed to get the system time zone";
114 }
115 i64 utcOffsetInMinutes = -tz.Bias;
116#endif
117 if (utcOffsetInMinutes == 0) {
118 os << 'Z';
119 } else {
120 if (utcOffsetInMinutes < 0) {
121 os << '-';
122 utcOffsetInMinutes = -utcOffsetInMinutes;
123 } else {
124 os << '+';
125 }
126 os << Pad<2>(utcOffsetInMinutes / 60);
127 if (iso) {
128 os << ':';
129 }
130 os << Pad<2>(utcOffsetInMinutes % 60);
131 }
132 }
133} // namespace
134
135template <>

Calls 4

WriteTmToStreamFunction · 0.85
MicroSecondsOfSecondMethod · 0.80
LocalTimeMethod · 0.45

Tested by

no test coverage detected