3 ms·
> While I got also shocked at first by Go's time formatting, is by far the easiest to learn and memorize once you get it. I completely agree. I've used strfti
by chimeracoder 12y ago
> While I got also shocked at first by Go's time formatting, is by far the easiest to learn and memorize once you get it.
I completely agree. I've used strftime and the like for years, and I still can't remember %m vs %M without thinking twice about it, at which point I usually just look at the docs to make sure I'm not making a mistake.
By contrast, as soon as I learned the "trick"[0] behind the canonical date in Go, I had it committed to memory, and I haven't needed to look it up once since.
YMMV, but personally, I'd much rather write "Jan" when I want a three-character month and "January" when I want a full month than try to remember that the former is %a and the latter is %A (...or is it the other way around? Time to check... again!)
[0] http://golang.org/pkg/time/#pkg-constants http://golang.org/pkg/time/#pkg-constants
- deathanatos 12y ago> I still can't remember %m vs %M without thinking twice about it The time component is "%H:%M:%S" — it's all capitals, and I always think "her majesty's ship" when I type it for some odd reason. At any rate, that's how I remember it. Once I work out that time component, then the date falls into place: "%m-%d-%Y". But yes, strftime's formatting strings aren't memorable. (I'm also a server-side engineer, so I active try to avoid formatting dates into anything other than ISO-8601…)
- Aissen 12y ago> By contrast, as soon as I learned the "trick" http://golang.org/pkg/time/#pkg-constants http://golang.org/pkg/time/#pkg-constants Since MST is GMT-0700, the reference time can be thought of as 01/02 03:04:05PM '06 -0700 Such sadness. Using a reversed month/year date as a "reference" when we have ISO 8601. Much american-centrism. Otherwise I like the trick, but I'm not sure it scales to locale-specific time formats (whereas strftime does a bit with %aAbBxX).
- burntsushi 12y agoThe line right above that one is the first cited reference format: Mon Jan 2 15:04:05 MST 2006
- Aissen 12y agoI know, I'm talking about the mnemonic used to remember this date.
- tracker1 12y agoI tend to prefer ISO-style dates/times myself... and unless the date+time is tied to a location+event (and not always then), store/transmit as UTC. This leads to far fewer headaches in the long run.