cosmopolitan
cosmopolitan copied to clipboard
tool/redbean: time machinery uses a different timezone
When e.g. logging, redbean doesn't use the system's timezone, preferring a different one instead:
C:\Users\user> wmic os get LocalDateTime /format:list
LocalDateTime=20230720012811.734000+120
C:\Users\user> redbean
I2023-07-19T16:28:13.079556:tool/net/redbean.c:7057:redbean:22652] (srvr) listen http://127.0.0.1:8080
>:
I2023-07-19T16:28:14.525606:tool/net/redbean.c:7082:redbean:22652] (srvr) received SIGINT
I2023-07-19T16:28:14+002001:tool/net/redbean.c:7089:redbean:22652] (srvr) shutdown complete
UTC-08:00 looks like Lower California - does it use a compile-time timezone?
Diagnostics:
redbean2.2 (from here)- Windows 10.0.19045.3208
- system TZ: UTC+01:00
Possibly related: #816
It does match for me, but I'm in the same timezone as CA (I'm in WA), so it's not a surprise:
>wmic os get LocalDateTime /format:list
LocalDateTime=20230719165305.129000-420
>redbean.com
I2023-07-19T16:53:07.613616:/zip/.lua/fullmoon.lua:60:redbean:12108] (fm) started redbean/2.2.0 fullmoon/0.376
I2023-07-19T16:53:07+000000:tool/net/redbean.c:7090:redbean:12108] (srvr) listen http://192.168.1.12:8080
I2023-07-19T16:53:07+000000:tool/net/redbean.c:7090:redbean:12108] (srvr) listen http://127.0.0.1:8080
I2023-07-19T16:53:08.676212:tool/net/redbean.c:7115:redbean:12108] (srvr) received SIGINT
I2023-07-19T16:53:08+000000:tool/net/redbean.c:7122:redbean:12108] (srvr) shutdown complete
I checked the logging and it's supposed to use the local time:
localtime_r(&t2.tv_sec, &tm);
strcpy(iso8601(buf32, &tm), sign);
I had to do this to get the correct local time on my Mac:
TZ=New_York ./redbean.com
What you're seeing is the default, which is defined here:
https://github.com/jart/cosmopolitan/blob/e0c2b91b3ec6f88d060d6059210a993a0ef46b08/libc/time/tzfile.internal.h#L28
and used here:
https://github.com/jart/cosmopolitan/blob/e0c2b91b3ec6f88d060d6059210a993a0ef46b08/libc/time/localtime.c#L383
This should have been fixed by b0df6c1fce30086bb2cefdd0079392fc2ad80edd in a lot of cases; if you are still having problems, please reopen.