News for hackers. Stuff that matters.
Re:Do not use 'week year': YYYY by layer8 on Tuesday January 04, 2022 @08:42AM (#29794580)
Format strings are intended to be configurable (possibly per user-interface language) and not necessarily hardcoded. A strongly-typed builder API might be useful, but if you need both programmatic specification and external configuration, format strings can fulfill both purposes, whereas only having a builder API doesn’t.
Re:Do not use 'week year': YYYY by jameshart on Tuesday January 04, 2022 @10:47AM (#29796010)
The best part is your format language can be extensible to support things like inline JNDI lookups...
Re:Do not use 'week year': YYYY by steerablesafe on Tuesday January 04, 2022 @09:02AM (#29794810)
That's perhaps true, but there is no reason why we can't have both. There are many hard-coded format strings in practice.
Re:Do not use 'week year': YYYY by layer8 on Tuesday January 04, 2022 @09:12AM (#29794912)
Right, my intent was to explain that format-string APIs are there for good reasons and not an arbitrary choice.
Re:Do not use 'week year': YYYY by yencabulator on Tuesday January 04, 2022 @10:31AM (#29795791)
`{year}-{month}-{date}` then.
Re:Do not use 'week year': YYYY by layer8 on Tuesday January 04, 2022 @10:51AM (#29796078)
More like `{numeric-year-no-leading-zeros}-{zero-padded-numeric-month}-{zero-padded-numeric-day-of-month}`. It’s virtually impossible to make it both succinct and unambiguous.