![]() |
|
Message-ID: <70c350e5-78cd-4ab9-ae9b-598179ee4f8e@pgbackrest.org> Date: Mon, 02 Jun 2025 19:33:41 +0000 (UTC) From: David Steele <david@...ackrest.org> To: musl@...ts.openwall.com Subject: Possible issue formatting epoch time with strftime() Greetings, I've been working on getting the pgBackRest unit tests working with musl libc. While there are some small differences from glibc that I have been able to work out I have found one issue that I can't solve or work around. Given the test program: #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { time_t time = 1573222014; char buffer[128]; setenv("TZ", "America/New_York", true); tzset(); strftime(buffer, sizeof(buffer), "%s", localtime(&time)); printf("local epoch: %s\n", buffer); strftime(buffer, sizeof(buffer), "%s", gmtime(&time)); printf("utc epoch: %s\n", buffer); strftime(buffer, sizeof(buffer), "%Y%m%d-%H%M%S", localtime(&time)); printf("local time: %s\n", buffer); strftime(buffer, sizeof(buffer), "%Y%m%d-%H%M%S", gmtime(&time)); printf("utc time: %s\n", buffer); } I get different output for musl vs gnu vs mac: Ubuntu 22.04 (UTC) gcc: local epoch: 1573222014 utc epoch: 1573240014 local time: 20191108-090654 utc time: 20191108-140654 Mac OS 15.4.1 (America/New_York) clang: local epoch: 1573222014 utc epoch: 1573240014 local time: 20191108-090654 utc time: 20191108-140654 Alpine 3.21 (America/New_York or UTC) gcc/musl: local epoch: 1573222014 utc epoch: 1573222014 <------ local time: 20191108-090654 utc time: 20191108-140654 I tried Alpine with system timezone set to America/New_York and UTC and got the same epoch result with both but formatting the time with %Y%m%d-%H%M%S give the expected result. Am I missing something? Please CC me as I am not subscribed to the list. Regards, -David
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.