Ancestors

Toot

Written by David Smith on 2024-12-16 at 18:03

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. (🤦🏻‍♂️)

=> View attached media

=> More informations about this toot | More toots from _Davidsmith@mastodon.social

Descendants

Written by Matt Massicotte on 2024-12-16 at 18:17

@_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

Written by Jordan Hipwell on 2024-12-16 at 18:27

@_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

Written by Alberto Sendra on 2024-12-16 at 19:19

@_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

Written by Joel LeBlanc on 2024-12-16 at 19:40

@_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

Written by Nonny de la Peña, Phd on 2024-12-16 at 21:10

@_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

Written by ROLLER on 2024-12-16 at 22:57

@_Davidsmith the concept of a Leap Week is pretty weird and sounds terrible!

=> More informations about this toot | More toots from roller@twit.social

Written by MacBalance on 2024-12-16 at 23:01

@_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

Written by argv minus one on 2024-12-16 at 23:32

@_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

Written by Pete Alex Harris🦡🕸️🌲/∞🪐∫ on 2024-12-17 at 08:39

@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

Written by argv minus one on 2024-12-17 at 21:01

@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

Written by Ryan Jones on 2024-12-17 at 02:15

@_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

Written by John Gruber on 2024-12-17 at 02:20

@_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

Written by Bruno Scheele on 2024-12-17 at 07:27

@_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

Written by Primatology (XYZ) · Oliver on 2024-12-17 at 09:17

@_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

Written by Sören Gade on 2024-12-17 at 09:33

@_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

Written by David Smith on 2024-12-17 at 16:08

@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

Written by Sören Gade on 2024-12-19 at 14:39

@_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

Written by Greg Parker on 2024-12-17 at 12:08

@_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

Written by Daniel Lyons on 2024-12-17 at 14:35

@_Davidsmith I still don’t understand what the heck is Week Of Year

=> More informations about this toot | More toots from dandylyons@iosdev.space

Written by Matthew Cassinelli on 2024-12-17 at 17:17

@_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

Written by mmalc on 2024-12-20 at 16:41

@_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

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113663817864136238
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
720.950786 milliseconds
Gemini-to-HTML Time
8.617029 milliseconds

This content has been proxied by September (ba2dc).