> What I'm trying to say is: even if you don't like Go, take a look at how Go's "time" library works. I think it would be valuable for other languages. Other languages can probably even do it better (imagining better type systems around units), but I've never seen an API that feels as right for manipulating time as Go's time stdlib.
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)) { ... }
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:
In Joda-Time, it could look like (all types are in org.joda.time): And in Boost.Date_Time (loosely based on this example[3]): 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...