> It might be nice if one day someone did either an addition to the
> existing time functions or another pkg to implement the Unix Date
> style +% format. I'd do this but I am still trying to get my head
> wrapped around this programming language as it is. :)
Oh, I hope not. The API in Go is much nicer.
-rob
I agree that the Go time API is very nice, but I can't help but wonder
whether there will arise issues due to the lack of an escape
possibility. e.g. what if you wanted the standard date as:
1/2 Monster TEAMSTER SHIPMENT 2006
Would the morning of February third in my timezone show up as
2/3 Thuster TEAPSTER SHIAMENT 2011
This is obviously a contrived example, but I can easily imagine
scenarios where numbers 1-7 might be used, or underscores might be
desired in a date in ambiguous locations.
I suppose the answer would be to call Format twice and concatenate the
strings together with the objectionable portions. Is there a better
answer than that, or a good reason why this kind of silliness won't
happen?
David
That's not the right question. The question is whether the complexity
added by trying to handle another case is balanced by the frequency
of that case coming up in practice. I am sure that the early idea for
strftime was simple: it was easier to remember %m/%d/%y than to
remember the magic constants in
printf("%d/%d/%d", t.tm_mon+1, t.tm_mday, t.tm_year+1900).
But the special cases that have been added make the patterns impossible
for people to interpret without resorting to documentation.
I think the litmus test is that if a function's usage is so hard to
remember that someone is motivated enough to create a domain and
web site whose only purpose is to make it easier to remember where
to find the documentation, then that function is broken. (http://strftime.org/)
Time.Format doesn't need to be the kitchen sink.
If you need more control, there is always fmt.Sprintf.
Unlike C's struct tm, Go's time.Time does not require
the addition of magic constants to turn struct fields into
printable values.
Russ