Skip to content

Commit fbab4bf

Browse files
derekmaurocopybara-github
authored andcommitted
Import of CCTZ from GitHub.
PiperOrigin-RevId: 788918981 Change-Id: I509a6a9bb3493c177cd4725383cd6e48b4479b68
1 parent 5694551 commit fbab4bf

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

absl/time/internal/cctz/src/time_zone_format.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ std::tm ToTM(const time_zone::absolute_lookup& al) {
117117
tm.tm_mday = al.cs.day();
118118
tm.tm_mon = al.cs.month() - 1;
119119

120-
// Saturate tm.tm_year is cases of over/underflow.
120+
// Saturate tm.tm_year in cases of over/underflow.
121121
if (al.cs.year() < std::numeric_limits<int>::min() + 1900) {
122122
tm.tm_year = std::numeric_limits<int>::min();
123123
} else if (al.cs.year() - 1900 > std::numeric_limits<int>::max()) {

absl/time/internal/cctz/src/time_zone_format_test.cc

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -169,45 +169,44 @@ TEST(Format, Basics) {
169169

170170
TEST(Format, PosixConversions) {
171171
const time_zone tz = utc_time_zone();
172-
auto tp = chrono::system_clock::from_time_t(0);
172+
auto tp =
173+
chrono::system_clock::from_time_t(308189482); // 1979-10-08T00:11:22Z
173174

174-
TestFormatSpecifier(tp, tz, "%d", "01");
175-
TestFormatSpecifier(tp, tz, "%e", " 1"); // extension but internal support
175+
TestFormatSpecifier(tp, tz, "%d", "08");
176+
TestFormatSpecifier(tp, tz, "%e", " 8"); // extension but internal support
176177
TestFormatSpecifier(tp, tz, "%H", "00");
177178
TestFormatSpecifier(tp, tz, "%I", "12");
178-
TestFormatSpecifier(tp, tz, "%j", "001");
179-
TestFormatSpecifier(tp, tz, "%m", "01");
180-
TestFormatSpecifier(tp, tz, "%M", "00");
181-
TestFormatSpecifier(tp, tz, "%S", "00");
182-
TestFormatSpecifier(tp, tz, "%U", "00");
183-
#if !defined(__EMSCRIPTEN__)
184-
TestFormatSpecifier(tp, tz, "%w", "4"); // 4=Thursday
185-
#endif
186-
TestFormatSpecifier(tp, tz, "%W", "00");
187-
TestFormatSpecifier(tp, tz, "%y", "70");
188-
TestFormatSpecifier(tp, tz, "%Y", "1970");
179+
TestFormatSpecifier(tp, tz, "%j", "281");
180+
TestFormatSpecifier(tp, tz, "%m", "10");
181+
TestFormatSpecifier(tp, tz, "%M", "11");
182+
TestFormatSpecifier(tp, tz, "%S", "22");
183+
TestFormatSpecifier(tp, tz, "%U", "40");
184+
TestFormatSpecifier(tp, tz, "%w", "1"); // 1=Monday
185+
TestFormatSpecifier(tp, tz, "%W", "41");
186+
TestFormatSpecifier(tp, tz, "%y", "79");
187+
TestFormatSpecifier(tp, tz, "%Y", "1979");
189188
TestFormatSpecifier(tp, tz, "%z", "+0000");
190189
TestFormatSpecifier(tp, tz, "%Z", "UTC");
191190
TestFormatSpecifier(tp, tz, "%%", "%");
192191

193192
#if defined(__linux__)
194193
// SU/C99/TZ extensions
195194
TestFormatSpecifier(tp, tz, "%C", "19");
196-
TestFormatSpecifier(tp, tz, "%D", "01/01/70");
197-
TestFormatSpecifier(tp, tz, "%F", "1970-01-01");
198-
TestFormatSpecifier(tp, tz, "%g", "70");
199-
TestFormatSpecifier(tp, tz, "%G", "1970");
195+
TestFormatSpecifier(tp, tz, "%D", "10/08/79");
196+
TestFormatSpecifier(tp, tz, "%F", "1979-10-08");
197+
TestFormatSpecifier(tp, tz, "%g", "79");
198+
TestFormatSpecifier(tp, tz, "%G", "1979");
200199
#if defined(__GLIBC__)
201200
TestFormatSpecifier(tp, tz, "%k", " 0");
202201
TestFormatSpecifier(tp, tz, "%l", "12");
203202
#endif
204203
TestFormatSpecifier(tp, tz, "%n", "\n");
205-
TestFormatSpecifier(tp, tz, "%R", "00:00");
204+
TestFormatSpecifier(tp, tz, "%R", "00:11");
206205
TestFormatSpecifier(tp, tz, "%t", "\t");
207-
TestFormatSpecifier(tp, tz, "%T", "00:00:00");
208-
TestFormatSpecifier(tp, tz, "%u", "4"); // 4=Thursday
209-
TestFormatSpecifier(tp, tz, "%V", "01");
210-
TestFormatSpecifier(tp, tz, "%s", "0");
206+
TestFormatSpecifier(tp, tz, "%T", "00:11:22");
207+
TestFormatSpecifier(tp, tz, "%u", "1"); // 1=Monday
208+
TestFormatSpecifier(tp, tz, "%V", "41");
209+
TestFormatSpecifier(tp, tz, "%s", "308189482");
211210
#endif
212211
}
213212

0 commit comments

Comments
 (0)