News for hackers. Stuff that matters.
Re:Arrow: Better dates and times for Python by fletchowns on Tuesday August 05, 2014 @06:33PM (#8139910)
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.
Re:Arrow: Better dates and times for Python by jbarham on Tuesday August 05, 2014 @06:52PM (#8139984)
Go's time package is nice (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.
Re:Arrow: Better dates and times for Python by sjy on Tuesday August 05, 2014 @10:09PM (#8140634)
That's a really cool idea. I'm always commenting my code with reference strings because format strings are so unreadable.
Re:Arrow: Better dates and times for Python by spankalee on Tuesday August 05, 2014 @06:55PM (#8139994)
The 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)

Re:Arrow: Better dates and times for Python by draegtun on Wednesday August 06, 2014 @08:10AM (#8142046)
Rebol 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/time.html
Re:Arrow: Better dates and times for Python by tdicola on Tuesday August 05, 2014 @09:18PM (#8140465)
I 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.
Re:Arrow: Better dates and times for Python by arethuza on Wednesday August 06, 2014 @04:33AM (#8141565)
I 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!
Re:Arrow: Better dates and times for Python by stygiansonic on Wednesday August 06, 2014 @09:25AM (#8142300)
Good 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.
Re:Arrow: Better dates and times for Python by briansfrank on Wednesday August 06, 2014 @09:52AM (#8142424)
Date/Time APIs are a core part of Fantom

http://fantom.org/doc/docLang/DateTime.html

Re:Arrow: Better dates and times for Python by jdnier on Wednesday August 06, 2014 @01:34PM (#8143684)
Date handling in PostgreSQL has always seemed ideal compared with what was available in Python. I'm happy to read about arrow.
Re:Arrow: Better dates and times for Python by jdnier on Wednesday August 06, 2014 @11:18PM (#8146133)
And I've been even happier reading about Delorean. http://delorean.readthedocs.org/en/latest/quickstart.html
Re:Arrow: Better dates and times for Python by hackerboos on Wednesday August 06, 2014 @05:12AM (#8141668)
Java pretty much absorbed Joda-Time in version 8.