4 ms·
Is there any language that got the date & time library right the first time? It seems like people always suggest to use a third party library. JavaScript has Mo
by fletchowns 12y ago
Is there any language that got the date & time library right the first time? It seems like people always suggest to use a third party library. JavaScript has Moment.js, Java has Joda-Time, and now Python has Arrow.
- jbarham 12y agoGo's time package is nice (http://golang.org/pkg/time/ http://golang.org/pkg/time/), although some people complain about parsing date/time strings using a reference string ("Mon Jan 2 15:04:05 -0700 MST 2006") vs. PHP or Python style format strings.
- sjy 12y agoThat's a really cool idea. I'm always commenting my code with reference strings because format strings are so unreadable.
- spankalee 12y agoThe Dart core library team was very conservative regarding dates and time for this reason. They kept things down to just DateTime (timezone aware, but only supports local and UTC) and Duration, and assumed that anything more advanced should be outside the core. I'm not sure if they got it right or not, but we haven't seen anyone want to replace the built in types yet. I think we've always expected a Joda-Time like library eventually, but hopefully DateTime and Duration are good, so it's additive. (I'm on the Dart team, but not on the core lib team)
- tdicola 12y agoI don't know if it was in there in the early versions of the .NET framework, but C# and .NET have decent time libraries standard. I didn't run into nearly as many warts and annoyances with .NET dates & times as I did with Python.
- arethuza 12y agoI agree - I came to Python after doing .Net and was surprised at how confusing the time/date handling is - particularly as pretty much everything else in Python is so nice!
- hackerboos 12y agoJava pretty much absorbed Joda-Time in version 8.
- draegtun 12y agoRebol comes built-in with nice date & time features. While it doesn't have all the bells and whistles you would get with a 3rd party library like the one posted here it does have an advantage that date & time are both first class datatypes: >> type? 6-Aug-2014 == date! >> type? 01:20:59 ; 1 hour, 20 mins and 59 secs == time! >> 6/8/2014 - 5/8/2014 == 1 >> difference 6/8/2014 5/8/2014 == 24:00 >> yesterday: now - 1 == 5-Aug-2014/13:12:33+1:00 >> yesterday/day == 5 >> one-hour-twenty-mins: 1:20 == 1:20 >> one-hour-twenty-mins/minute == 20 >> one-hour-twenty-mins/hour == 1 >> two-hours: one-hour-twenty-mins + 0:40 == 2:00 refs: http://www.rebol.com/r3/docs/datatypes/date.html http://www.rebol.com/r3/docs/datatypes/date.html | http://www.rebol.com/r3/docs/datatypes/time.html http://www.rebol.com/r3/docs/datatypes/time.html
- stygiansonic 12y agoGood point. Date & Time is one of those subjects that seems relatively easy to the uninformed, but actually requires some pretty careful consideration and domain-specific knowledge to get correct.
- briansfrank 12y agoDate/Time APIs are a core part of Fantom http://fantom.org/doc/docLang/DateTime.html http://fantom.org/doc/docLang/DateTime.html
- jdnier 12y agoDate handling in PostgreSQL has always seemed ideal compared with what was available in Python. I'm happy to read about arrow.
- jdnier 12y agoAnd I've been even happier reading about Delorean. http://delorean.readthedocs.org/en/latest/quickstart.html http://delorean.readthedocs.org/en/latest/quickstart.html