Earlier quoted context omitted.
Do you have any examples of annoying to parse time formats?
http://play.golang.org/p/hCoZ3tdeM_ am I doing this correctly? Because it seems that golang does not recognize the abbreviations at all.
Time in Go
11–20 of 80 posts
Re: Time in Go
#12I prefer the C way with the struct and format.
How do I get the time offset to UTC time at a given date and location ?
Re: Time in Go
#13I'm surprised about the method to define a time format by example. There could be an ambiguity between month and day if the example is badly chosen. I prefer the C way with the struct and format. How do I get the time offset to UTC time at a given date and location ?
Re: Time in Go
#14More languages should copy Go's time library. As someone who has written a lot of Go for years, I am always very quick to say that "time" is my favorite Go standard library. I love it. The "time" library is to Go what the "requests" [non-standard] library is to Python, in terms of a great API and simplicity. For some reason in every other language I've used (important, I don't know every time library! :P) the time li…
Then you might be interested in Joda-Time[1] and Boost.Date_time[2]. I'm not saying they are better or worse than Go's time library. They are quite powerful in their own right however.
Taking the example you presented:
take the more generic problem of: I have
a time, I have a duration, how do I tell
if that duration has passed?
In Joda-Time, it could look like (all types are in org.joda.time): new Interval (yourStartDate, theDuration).contains (
candidate
);
And in Boost.Date_Time (loosely based on this example[3]): date d = day_clock::local_day ();
time_period allDay (ptime (d), ptime (d, hours (24)));
if (allDay.contains (someTimeInstance)) { ... }
1 - http://joda-time.sourceforge.net/userguide.html2 - http://www.boost.org/doc/libs/1_59_0/doc/html/date_time.html
3 - http://www.boost.org/doc/libs/1_59_0/doc/html/date_time/exam...
Re: Time in Go
#15Re: Time in Go
#16 fmt.Printf("\n... and %v days after that ...\n", days)
t2 := t1.Add(time.Duration(days) * time.Hour * 24)
printTime(t2)
How is that supposed to work with daylight saving time? Won't t2 end up one hour off from t1 if there is a daylight saving shift?Re: Time in Go
#17Earlier quoted context omitted.
Do you have any examples of annoying to parse time formats?
http://play.golang.org/p/hCoZ3tdeM_ am I doing this correctly? Because it seems that golang does not recognize the abbreviations at all.
I can only assume that the time zone name alone is insufficient to resolve ambiguous times.
Re: Time in Go
#18Earlier quoted context omitted.
Do you have any examples of annoying to parse time formats?
I can find it later, but I just had this issue this week with timestamps sent from a browser, supposedly in RFC3339, but Go's RFC3339 format was not compliant with it. So naturally I made my own format template. Alas, the milliseconds part had arbitrary precision, which Go's parser doesn't like. So I had to revert to trying the timestamp with one, two ,three trailing digits, etc. Still, this is the only issue I have…
Re: Time in Go
#19So I copied the example from http://golang.org/pkg/time/#Parse and it did NOT work as expected: http://play.golang.org/p/Xd9oEeSffd (timezone offset is zero)