10 ms·
Notice there is no format in which timezone is specified as 4 digits without the colon, and yet 'date +%z' returns ±NNNN.
by cratermoon 3y ago
Notice there is no format in which timezone is specified as 4 digits without the colon, and yet 'date +%z' returns ±NNNN.
- aendruk 3y agoThankfully we have %:z. Relatedly, it’s possible to teach date to do this by default: https://gist.github.com/d081dad407432d53172e30d0d35c39db https://gist.github.com/d081dad407432d53172e30d0d35c39db $ date 2023-08-31T11:15:00-07:00
- cratermoon 3y ago+%:z is a gnu-specific extension, though. The gist you linked works with gnu libc, but I'm not aware of a POSIX-compliant way to do it.
- ijmacd 3y ago> timezone is specified as 4 digits without the colon ±NNNN is valid (without colon) if used as part of the "basic" format. i.e. no hyphens or colons anywhere in the format. Thus the following are equivalent and both valid: 2023-09-01T09:40:01+08:00 20230901T094001+0800
- cratermoon 3y agoAh, I see that listed as a valid ISO 8601 format in the table, but not in the visualization, so I missed it. Also I can't say I've ever seen the basic format in the wild, is there anywhere it's used regularly?
- chipsa 3y agoWhen the timestamp gets slammed into a file name, as the colon is reserved on Windows and MacOS. Also, when space matters, as it's very slightly shorter.