Skip to content

Commit 6bdc7e2

Browse files
dschuffkripken
andauthored
Use a fixed timestamp for test_strftime_zZ (#22796)
This test was using the current time test timezone offsets, but that approach fails when the local UTC offset changes for DST/summer-time. Instead, use a fixed timestamp for an unchanging date. --------- Co-authored-by: Alon Zakai <[email protected]>
1 parent aa3a8a4 commit 6bdc7e2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

test/other/test_strftime_zZ.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include <time.h>
55

66
int main() {
7-
void tzset(void);
8-
97
// Buffer to hold the current hour of the day. Format is HH + nul
108
// character.
119
char hour[3];
@@ -20,8 +18,9 @@ int main() {
2018

2119
struct tm tm;
2220

23-
// Get the current timestamp.
24-
const time_t now = time(NULL);
21+
// Use a timestamp corresponding to July 2024, to avoid depending on the
22+
// current time (which may fail e.g. when DST/summer-time changes).
23+
const time_t now = 1719792000;
2524

2625
// What time is that here?
2726
if (localtime_r(&now, &tm) == NULL) {

0 commit comments

Comments
 (0)