This is your periodic reminder that you almost certainly never mean “YYYY" in a date format string, you probably mean “yyyy”.
I’ve made this mistake many times, most recently back in 2020, but apparently I'm a very slow learner and made it again in my last update (😔).
You know you've really messed up when checking your understanding leads to one of these super vintage iOS documentation pages, and they specifically call out your mistake. (🤦🏻♂️)
=> More informations about this toot | More toots from _Davidsmith@mastodon.social
@_Davidsmith The best part about this is when it causes a bug you can say “why why why why” and that is both the reason and solution
=> More informations about this toot | More toots from mattiem@mastodon.social
@_Davidsmith you probably want "y" when it’s displayed to the user for proper localization :)
=> More informations about this toot | More toots from jordanhipwell@mastodon.world
@_Davidsmith I would set up a SwiftLint rule to catch this at build time
=> More informations about this toot | More toots from asendra@mastodon.online
@_Davidsmith This is not your fault. It’s a bad interface. It should say “wwww” or some such thing, and the fact that the mistake is made is proof the interface is wrong.
The interface serves the community, never the other way around.
=> More informations about this toot | More toots from jwleblan@mastodon.social
@_Davidsmith the fact that you are still worrying about that and there isn’t a code auto-correct makes me crazy. When I used to code more null reference exceptions drove me insane - one letter accidentally capitalized in c# but not in the unity game engine interface…
=> More informations about this toot | More toots from Nonny@mstdn.social
@_Davidsmith the concept of a Leap Week is pretty weird and sounds terrible!
=> More informations about this toot | More toots from roller@twit.social
@_Davidsmith Is this something that would potentially give odd results at the end of the year? As in the last week of the year is always part of the outgoing year even on January 1st to whenever?
=> More informations about this toot | More toots from MacBalance@mstdn.games
@_Davidsmith
This is why I'm not fond of yyyy-MM-dd
notation. I'd much rather specify date/time formats using named fields, like the Rust time
crate does.
Example: [year]-[month]-[day] at [hour]:[minute]
Result: 2024-12-16 at 15:32
=> More informations about this toot | More toots from argv_minus_one@mastodon.sdf.org
@argv_minus_one @_Davidsmith
At work, in Python, I generally recommend date.isoformat()
Generally we just want sortable date strings with hyphens. Less code is better code.
=> More informations about this toot | More toots from petealexharris@mastodon.scot
@petealexharris
Yes, that too. Any well-stocked date-formatting library should have ready-to-go support for the RFC3339/ISO8601 format.
@_Davidsmith
=> More informations about this toot | More toots from argv_minus_one@mastodon.sdf.org
@_Davidsmith would be hilarious to input yyyy as a text replacement for YYYY on your Mac 😂
=> More informations about this toot | More toots from rjj@mastodon.social
@_Davidsmith Now I'm wondering how many places I've left YYYY
and not noticed.
=> More informations about this toot | More toots from gruber@mastodon.social
@_Davidsmith Back when documentation was way better. What I’d give for a ‘Common mistakes’ section in the more recent articles.
=> More informations about this toot | More toots from brunoscheele@mastodon.social
@_Davidsmith I’ve never made that mistake because I’m incapable of remembering the syntax and have to read the documentation. Every. Single. Time.
=> More informations about this toot | More toots from primatologyxyz@mastodon.social
@_Davidsmith Is there a reason you are using this, and not Swift‘s formatting APIs, or DateComponents with a formatter?
=> More informations about this toot | More toots from sense@mastodon.social
@sense I use a combination of both but also have some code which predates the Swift Formatting APIs and want uniformity across the codebase.
=> More informations about this toot | More toots from _Davidsmith@mastodon.social
@_Davidsmith Makes sense. Are there certain API differences that you require, where the newer APIs fall short for your requirements? Sounds like an interesting topic since the ergonomic (and error potential) of the newer APIs seems far ahead.
=> More informations about this toot | More toots from sense@mastodon.social
@_Davidsmith We need someone to pick up ckane’s old work on date format string diagnostics.
=> More informations about this toot | More toots from gparker@discuss.systems
@_Davidsmith I still don’t understand what the heck is Week Of Year
=> More informations about this toot | More toots from dandylyons@iosdev.space
@_Davidsmith The Format Date action in Shortcuts has led me to have an unnecessarily close relationship with these standards
=> More informations about this toot | More toots from matthewcassinelli@mastodon.social
@_Davidsmith
Hahaha.
I wrote that.
If I were writing it today I'd probably add the caution that the years don't match at the end of the year when you're probably least likely to be testing it.
And in the case of certain apps afflicted by the issue since the time of writing, when you least want to be called back to the office for a frantic P1.
See also #EventHorizonOfDoom
When you first get reports of a related issue on New Year's Day from New Zealand…
CC @pbur
=> More informations about this toot | More toots from mmalc@mastodon.social This content has been proxied by September (ba2dc).Proxy Information
text/gemini