Skip to content

Commit

Permalink
Use a fixed timestamp for test_strftime_zZ (#22796)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dschuff and kripken authored Oct 28, 2024
1 parent aa3a8a4 commit 6bdc7e2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test/other/test_strftime_zZ.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <time.h>

int main() {
void tzset(void);

// Buffer to hold the current hour of the day. Format is HH + nul
// character.
char hour[3];
Expand All @@ -20,8 +18,9 @@ int main() {

struct tm tm;

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

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

0 comments on commit 6bdc7e2

Please sign in to comment.