4 ms·
The Go date format is one my huge annoyances about the language (not generics, interface{} magic, or the lack of immutable types). My biggest issue is that desp
by nemothekid 12y ago
The Go date format is one my huge annoyances about the language (not generics, interface{} magic, or the lack of immutable types). My biggest issue is that despite the fact the designers call Strftime bad because no one remembers the letters, and has to have documentation handy - the Go docs don't even document the magic numbers you have to use.
Why 2006? How do I represent a day? When do I use _2 vs 2? Its very poorly documented and thankfully all I use is RFC3339 and Unix timestamps.
- enneff 12y agoIf you ask "Why 2006?" then you missed the point. Mon Jan 2 15:04:05 -0700 MST 2006 0 1 2 3 4 5 6 How to represent a day? "2". Want a leading zero? "02".
- nemothekid 12y agoAgain, where in the documentation is this listed? Why is the timezone 7 even though its before the year? Did you just make this up? It seems to me that this might just be a happy coincidence in the way you ordered the date.
- tedunangst 12y agoIt's in the documentation right where you'd expect it to be. http://golang.org/pkg/time/#pkg-constants http://golang.org/pkg/time/#pkg-constants
- jerf 12y agoHere, directly below the actual listing of the constants: http://golang.org/pkg/time/#pkg-constants http://golang.org/pkg/time/#pkg-constants But I would also observe I missed this documentation myself a couple of times, and I think it probably should have gone on the package documentation, so while I'm linking you to this, I'm not necessarily disagreeing that it's misplaced a bit.
- enneff 12y agoIt's in the documentation for the Format method, which is where I'd expect to find it: http://golang.org/pkg/time/#Time.Format http://golang.org/pkg/time/#Time.Format That it's in order is an intentional mnemonic. I'm not sure why the 7 comes later, but appears earlier.