Go Date Format
fuckinggodateformat.com
fuckinggodateformat.com
The argument from the issue https://github.com/golang/go/issues/444
> It would be much easier to port preexisting code if you could just copy your time formats over.
It's not really much of an argument, since transforming the sprintf format to Go is a trivial as printing an specific date.
Every time I have to pick up the docs because Is day the 1st or month the 1st? Ms and Ns which number? Timezone?
I think that the decision of golang to use this way is really unfortunate and yet more lazy than people that don't want to learn yet another (useless) thing.
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!)
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…)
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).
Mon Jan 2 15:04:05 MST 2006The format string "4 minutes after 12", is unique, but it's not clear that I could turn "34" into "4". Similar for the hour (12 is now 2).
That would also break the "Print this exact time in the format you're currently using" method of creating a compatible time format string.
We have a perfectly good, unambigious date and time format. It's true that many users are deeply committed to ambiguous formats, but we should at the very least be trying to dissuade them from using them by making ISO formats the default.
No, the timezone string is messed up:
2006-01-02T15:04:05Z07:00
If they had picked
2000-01-02T15:04:05Z06:00
(03 would make more sense but then there would be issues with 12h vs 24h clock)
then they could even express ISO 8601 week number and the corresponding year. Something which is not possible at the moment. Although more difficult to remember it would be 52 and 1999. (For the 2006 it is 01 and 2006 not distinguishable)
There are some mature languages with an active "modding" community. Haskell, for example.
Which we have. Several groups have done this. eg http://docs.paralleluniverse.co/quasar/
Besides, users of a library in language X don't want to have to read language Y to look under the hood.
We do have those. In this case the common library is called "libc." In this case (and in a few others) the Go team decided to intentionally avoid providing an interface to this function.
The good news is it would take just a few minutes to add support for go to call strftime directly from libc.
No, you don't. You can use one of the 30 existing ways of formatting dates from other languages. You might have to implement it yourself but you don't have to design it yourself.
This is a symptom of the main problem with Go. Its creators either don't know about or have chosen to ignore most of the last few decades of language design and do their own thing when it doesn't add anything significant. And no, they don't do concurrency differently: coroutines have been around for a long time.
Unfortunately there are also some downsides to the virtual machine approach but I still think there's a window of opportunity open here for Microsoft if they make the CLR robust and reliable on Mac and Linux.
You can't change everything, but it's what you do differently that gives your project value.
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.
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".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.
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.
Personally I see no problem with this being a WONTFIX. I wouldn't even have built the flipping thing in the first place. (I might have built the fucking thing, though.)
Huh?
Who can remember the numbers? The only way to use this format is with the documentation.
It is an easier to read and verify format. However if you think a casual user will remember that "02" is hour and "03" is... wait, is 02 hour? Let me check the documentation.
1 2 3 4 5 6 => January, 2, 03:04:05pm, 2006
While there's a lot to say for sticking to your language's idioms even when it's a pain, if you really need/want strftime there are third-party libraries:
Did you mean strftime?
If I see a Go programmer import a sprintf library just because he doesn't want to conform to the programming environment, that's going to ruffle some feathers during code review.
But if he uses this, well, I'd be none the wiser.
Readability counts.
Oh yeah: `01200602150405`
But in this case, you're programming Go already. Better stick with the tools that everyone knows and expects. In .go files, Go code is more readable. In .py, it's not.
People who read your Go code will know Go, and they will be in "Go mode". To them a Go-style date formatting string will make more sense than a sprintf one.
Suffice to say, it was not intuitive at all. I had to look at the support forums to learn about this Go eccentricity.
I can't say that I hate it. I could probably get used to it.
But then I noticed they decided to tackle the dd-MM-yyyyTHH:mm:ss problem AKA crazy case. Which is kind of noble.
my oh my, my slightly blurred vision is having fun
A little bit of history. I don't remember exactly when in the 90's it changed but at a certain point there were actually certain words banned from being used in domain registrations.
Isn't that censorship? Maybe that's why it changed...
I'd rather either patch Go or focus on something positive/productive for an hour.
Call me crazy.
1- Using names for software that is confusing with names of real things that have nothing to do with it, like Cocoa for a user interface library and so many others.
2- Using the terms a two year old will use when she discovers it is funny and gets attention just for saying dirty words.
In this particular case, this combines both in one. The first thing I thought was: This will have something to do with dating and having casual sex or something. Then you discover that no, it has nothing to do with it, it is just a two year old like mindset creating a "funny"(for him) name for their pet project.
So, preffering what a prude 50 year old from some place with a strong puritan culture would want to see.
A kid does not find funny what it is not "tabu" or "forbidden".
Why do you allow mere words to have such control over you?
What?
Also, have you tried http://flippinggodateformat.com/ ? It seems they took your considerations into account.
The words "Go"(to go, not the language), "Date"(having a date), and "fucking" in the same place.
Those words have different meanings, and in fact those meanings are the normal meaning for most of the people in the street.
That title wouldn't make sense for most of the people in the street. In the best case they would probably ask who's Format (but take my words with a grain of salt as I'm not a native English speaker).
I suppose some people are offended by my words, but by using inappropriate words on a HN tittle offends me and other people too.
They may also not have understood how you were offended by the article.
I worked in a hospital for four years with a 50% patient load who were kids, most of who were around two years old (that's when the test I performed had it's greatest effect) and often distressed. You know what the naughty word two-year-olds use is? It's "No". I never heard a two-year-old say 'fuck' or any such derivative, and I saw families from all walks of life.
I'm tired of how moralisers make this kind of bullshit up. If you don't like the language, fine, say that. Say it directly. But this kind of demeaning crap is passive-aggressive - ironically not something that a mature commentary should involve.