2 ms·
> or fail noisily if it's not aware of that offset code. But it is aware of it! You just told it, using the TZ variable, what EDT is. It's a timezone called ED
by phaemon 6y ago
> or fail noisily if it's not aware of that offset code.
But it is aware of it! You just told it, using the TZ variable, what EDT is. It's a timezone called EDT, with no offset from UTC!
If you wanted an offset, you should have written `TZ=EDT+4 date`
- treesprite82 6y agoIf I'm understanding the examples, it looks like (in general) commands such as `TZ=EST date` work as expected (i.e. you can set offset just using the offset code). > But it is aware of it! You just told it The user didn't intend to. Defining a new offset code should be explicit, not a silent fall-back when it's unable to find EDT.
- phaemon 6y ago> The user didn't intend to. Well, they should have read the docs. They clearly show examples of how to define a timezone right there. It isn't a fallback, it's what TZ is for. Edit: perhaps `date` should have a `-z --zoneinfo` option, in which you could specify a timezone by file and it would fail if the file did not exist. This would fix the issue and avoid breaking existing scripts.
- treesprite82 6y ago> Well, they should have read the docs You can say that about any bad design choice, and in this case I'd argue that the linked docs don't even agree with the behaviour. The syntax given by the docs for creating a new timezone requires explicitly specifying an offset (then optional stuff like daylight savings). The quirk may be documented elsewhere, but before getting caught out by it the average user has no reason to be searching through multiple sources of documentation for an oddity they don't yet know exists. > It isn't a fallback, it's what TZ is for. If I'm understanding, `TZ=EDT` will search for an "EDT" timezone in its database, fail, then instead silently default to creating a new timezone with 0:00 offset. That's pretty much how I'd define a fall-back.
- steerablesafe 6y agowhy doesn't this work the same way for 'EST' then? You don't specify offset so it should just display in UTC as well, right?
- phaemon 6y agoBecause it has additional information in a file in `/usr/share/zoneinfo`. But you can still define a brand new timezone with the TZ variable. Perhaps you want to argue that you shouldn't be able to, but that's what it's for, as the document linked above clearly states.