Open jnd-au opened 1 week ago
-when 0
behave to match the UNIX epoch. 👍🏻 If we add support for RFC3339 dates, we're opening the door to many many more human friendly (and non-human friendly) representations too. Like + 1 week
, +1d
, years, days, or all of go's time durations, and the many incompatible date formats in existence.
Relying on established tools like date
works fine.
tz -when $( date -d '+3 month' +%s )
(or date -v+3m +%s
on MacOS/BSD).tz -when $( date -d "2024-10-28T15:10:06Z" +%s )
, or date -j -f "%Y-%m-%dT%H:%M:%SZ" "2024-10-28T15:10:06Z" +%s
on MacOS/BSD (yay).Okay, but hopefully you will reconsider the latter. ISO 8601 / RFC 3339 are standard and common, not random, and it would be good for tz
to support at least one standard, international, platform-independent format. UNIX seconds are a platform-specific notion, and as you noted above, date
isn’t even standard between GNU/Linux and BSD. UNIX seconds are especially inconvenient and unintuitive for Windows users, who face multiple steps to use -when
with PowerShell e.g. have to convert the time to UTC, then convert to UNIX seconds, then trim the fractional part because tz won’t parse it.
Currently
tz -when 0
will show the current (real) time instead of the UNIX epoch 0. This is a counter-intuitive and unfortunate. It would be good if-when 0
works the same way as-when 1
and-when -1
. It would also be nice if ISO 8601/RFC 3339 date-times could be parsed, as this meanstz
would become quite versatile for developers to see and convert between seconds and timestamps.