5 ms·
> Go's "time" library is deceptively simple. Has any language initially shipped with a non-broken date / time library? (See: SQL, java, python,...) Clearly a
by shellac 11y ago
> Go's "time" library is deceptively simple.
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'.
- buffoon 11y ago.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));
- itsjustjoe 11y agoI'm going to have to disagree. DateTime is pretty limited, especially when it comes to timezones. I highly recommend NodaTime instead.
- steveklabnik 11y agoWith 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.
- shellac 11y ago> 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). :-)
- kibwen 11y ago> 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/ https://lifthrasiir.github.io/rust-chrono/chrono/
- mayoff 11y agoApple's date/time support (part of the Foundation framework in both iOS and Mac OS X) is fantastic. Better than anything else I've ever seen.