cosmopolitan icon indicating copy to clipboard operation
cosmopolitan copied to clipboard

tool/redbean: time machinery uses a different timezone

Open mataha opened this issue 2 years ago • 2 comments

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:

  • redbean 2.2 (from here)
  • Windows 10.0.19045.3208
  • system TZ: UTC+01:00

Possibly related: #816

mataha avatar Jul 19 '23 23:07 mataha

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);

pkulchenko avatar Jul 19 '23 23:07 pkulchenko

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

michaellenaghan avatar Jul 24 '23 18:07 michaellenaghan

This should have been fixed by b0df6c1fce30086bb2cefdd0079392fc2ad80edd in a lot of cases; if you are still having problems, please reopen.

mrdomino avatar May 18 '24 23:05 mrdomino