
Go Date Format - shenoybr
http://fuckinggodateformat.com/
======
vruiz
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.

The argument from the issue
[https://github.com/golang/go/issues/444](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.

~~~
chimeracoder
> 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)

~~~
Aissen
> 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
The line _right above_ that one is the first cited reference format:

    
    
        Mon Jan 2 15:04:05 MST 2006

~~~
Aissen
I know, I'm talking about the mnemonic used to remember this date.

------
BenDaglish
Personally, when I first read the spec. for time.Format, I thought "well how
bleedin' sensible is that?!" The _only_ thing that annoys me is that it isn't
in ISO order (I'd have preferred 2001-02-03 14:05:06 ), but all that you need
to remember is "2006-01" and the rest just falls naturally into place. I've
seen a couple of "complaints" about this over the last few days, and I just
don't understand what the problem is. It's logical and neat.

~~~
ustolemyname
ISO ordering would make expressing time in AM/PM ambiguous, i.e. the format
string "2:05PM".

~~~
lifthrasiir
12:34:56 2007-08-09 would work equally, though. (EDIT: oops, no.)

~~~
ustolemyname
How do I cleanly express single digit minutes?

The 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.

------
Normati
It's unfortunate that languages are so monolithic. You want to make a language
that does concurrency differently and you end up having to design date format
strings! Sad that we still don't have any kind of common libraries or whatever
it might take to just do this a couple of times and let language designers
pick and choose the preexisting components they want.

~~~
throwaway90999
"Sad that we still don't have any kind of common libraries or whatever"

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.

------
elmin
I, for one, deeply appreciate any project which isn't afraid to do things
differently when they decide there's a better way. I see it similar to iOS not
supporting Flash, or Angular 2.0 rethinking things.

You can't change everything, but it's what you do differently that gives your
project value.

~~~
dap
Sure, but date formatting? That's where Go is going to differentiate itself?
Even though it still uses a C-like format string? This seems like exactly the
kind of area where leveraging the existing conventions would be a no-brainer.

~~~
pb2au
It isn't the format string syntax that is the problem that they're trying to
solve. I see this as being an iterative, backwards-incompatible improvement on
the existing format convention. Changes in convention don't have to be all or
nothing.

------
lohengramm
I personally love the way it works. This is actually one of my arguments in
favor of the golang standard library which is, in my opinion, a great piece of
software by itself.

------
nemothekid
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
If 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
Again, 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.

~~~
jerf
Here, 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.

------
svisser
Strangely the non-profanity version
[http://flippinggodateformat.com](http://flippinggodateformat.com) still has
profanity.

~~~
bdotdub
Ha my bad. Fixed :)

~~~
wging
It still has profanity, in the form of a link to
[http://fuckinggodateformat.com/](http://fuckinggodateformat.com/) :)

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.)

------
YesThatTom2
I generally agree with Cox but "no one remembers all the letters, so the only
way to use it is with documentation in hand."

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.

~~~
bdotdub
While it seems random, it is simply:

1 2 3 4 5 6 => January, 2, 03:04:05pm, 2006

~~~
jesstaa
It's 1,2,3,4,5,6 in the default format of the posix 'date' command.

------
twotwotwo
First: neat, funny ("I can now write Go date format strings...you win this
time"), and I follow the "sprintf may be awful but at least I know it"
argument.

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:

[https://github.com/search?l=Go&q=strftime](https://github.com/search?l=Go&q=strftime)

------
adsche
> Because I've used sprintf a million times before

Did you mean strftime?

~~~
jrockway
That's different too, of course. Everything is %v. Just use %v.

------
nothrabannosir
People who say "he could just use sprintf" are missing the point: this lets
you use sprintf _while writing idiomatic Go_.

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.

~~~
DAddYE
> Readability counts.

Oh yeah: `01200602150405`

~~~
nothrabannosir
Look, I'm not trying to make an argument for how good or bad Go's string
formatting is. Tbh I forget both and I find myself back in the documentation
either way.

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.

------
arvinsim
I just recently had this problem while working with Hugo, a Go static site
generator.

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.

------
guard-of-terra
I was wondering why they didn't borrow java SimpleDateFormat

But then I noticed they decided to tackle the dd-MM-yyyyTHH:mm:ss problem AKA
crazy case. Which is kind of noble.

------
adwf
I understand there may be legacy issues from other languages, but in a new
language... why on earth would you not take the time to make %p the lower case
am/pm and %P - AM/PM?

------
f2f
TIL that the hardest thing to do in computer science is to learn something new
and different.

~~~
bdotdub
I think the real lesson here is developers have a warped sense of time and
would rather spend relatively much more time building a website to solve a
problem than it would just to learn it

------
RubyPinch
grey on white, lightgrey on white, yellow on white

my oh my, my slightly blurred vision is having fun

------
squiguy7
I'm no designer but that yellow color used on the site is not easy to read.

------
pbreit
I appreciate the "flipping" version but why such an obnoxiously immature
primary domain?

~~~
larrys
I agree with you (and upvoted you). The reasons is simple to express emotion
and obviously to get attention.

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.

~~~
vhost-
>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...

------
peterwwillis
Who the fuck _buys a domain name and sets up a web site_ just because they're
frustrated at a date format? I don't get kids today.

~~~
frikk
$8/year, for fun. Why not? Probably took an hour to do.

~~~
peterwwillis
I can do a lot of things in an hour. I could yell out my window for an hour. I
could rant on irc for an hour. I could write a blog post about how pissed I am
for an hour. I could register a domain name, make a website, host and publish
it on news sites, then track the comments of people who comment on it, in an
hour.

I'd rather either patch Go or focus on something positive/productive for an
hour.

Call me crazy.

------
Htsthbjig
There are two thing I don't like in IT:

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.

~~~
coldtea
> _Using the terms a two year old will use when she discovers it is funny and
> gets attention just for saying dirty words._

So, preffering what a prude 50 year old from some place with a strong puritan
culture would want to see.

~~~
Htsthbjig
For me puritan culture is exactly what makes someone believe this is funny
when it is not.

A kid does not find funny what it is not "tabu" or "forbidden".

~~~
Gigablah
"Not funny" doesn't mean "offensive".

Why do you allow mere words to have such control over you?

