acassis commented on PR #9578: URL: https://github.com/apache/nuttx/pull/9578#issuecomment-1599718486
@michallenc talking about time and timezone, I think I found an issue on NuttX, it is generating 00:00 AM/PM (for US people 00:00 never exists, it is always 12:00 AM/PM). I'm using strftime with "%I" instead "%H" (see: https://stackoverflow.com/questions/1759455/how-can-i-account-for-period-am-pm-using-strftime) We can try this same program on Linux and NuttX: ``` #include <time.h> #include <stdio.h> #include <stdlib.h> void print_time(time_t t) { char buf[256]; strftime(buf, sizeof buf, "%H:%M %p", localtime(&t)); printf("%s %s\n", getenv("TZ"), buf); } int main() { time_t t = time(NULL); setenv("TZ", "Europe/London", 1); print_time(t); setenv("TZ", "America/New_York", 1); print_time(t); return 0; } ``` Testing on Linux with %H and then with %I: $ ./tztest Europe/London 00:11 AM America/New_York 19:11 PM $ ./tztest Europe/London 12:11 AM America/New_York 07:11 PM Testing on NuttX with "%H" nsh> hello Europe/London 00:00 AM America/New_York 00:00 AM nsh> Testing on NuttX with "%I" nsh> hello Europe/London 00:01 AM America/New_York 00:01 AM nsh> I suspect that strftime() also is ignoring the "TZ" environment variable. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org