Re:Time in Go
by steveklabnik on Thursday September 10, 2015 @12:06PM
(#10198831)
With Rust, we pulled time out of the standard library before 1.0, specifically because we knew it wasn't up to the task. So if "no library" counts as a "non-broken" library...
We still don't have great libraries yet, but they're coming, slowly. Chrono is pretty good.
> Chrono is pretty good.
For purposes of comparison to other libraries, here's a link to Chrono's documentation: https://lifthrasiir.github.io/rust-chrono/chrono/> With Rust, we pulled time out of the standard library before 1.0, specifically because we knew it wasn't up to the task.
This honestly strikes me a very good response. Saddling a still-growing community with sub-par core datatypes is worse than their absence.
> So if "no library" counts as a "non-broken" library...
Of course if I had phrased my question in terms of the 'first shipped date / time library' then Rust still has a chance to follow this illustrious trajectory for languages (i.e. really mess up). :-)
.Net's is pretty good.
var date = DateTime.UtcNow.AddDays(24).AddYears(-10);
In use: var billFor = 12; // months
var firstDayOfMonth = DateTime.Today
.AddDays(1 - DateTime.Today.Day);
var billDates = Enumerable.Range(billFor)
.Select(n => firstDayOfMonth.AddMonths(n));
Re:Time in Go
by itsjustjoe on Friday September 18, 2015 @01:46PM
(#10240777)
I'm going to have to disagree. DateTime is pretty limited, especially when it comes to timezones. I highly recommend NodaTime instead.
Has any language initially shipped with a non-broken date / time library? (See: SQL, java, python,...)
Clearly a very hard thing to get right, but post-JodaTime there a fewer excuses for APIs like:
> AddDate(y, m, d) to add a given number of years, months, days:
which pretty much defines 'deceptively simple'.