janet icon indicating copy to clipboard operation
janet copied to clipboard

os/date should be able to handle a given timezone.

Open amano-kenji opened this issue 2 years ago • 3 comments

For, example

(os/date (os/time) "America/New_York")

amano-kenji avatar Jun 09 '22 05:06 amano-kenji

On POSIX systems this might work for you:

(os/setenv "TZ" "America/New_York")
(os/date (os/time) true)

zevv avatar May 11 '23 16:05 zevv

This is non-trivial while maintaining strict ISO C99 compatibility (or, indeed, strict ISO C-anything compatibility), as it does not specify any way of doing this. On POSIX, setting TZ is indeed the correct approach though.

CosmicToast avatar May 11 '23 18:05 CosmicToast

@zevv I think os/date should document TZ environment variable, then.

amano-kenji avatar May 12 '23 05:05 amano-kenji