News for hackers. Stuff that matters.
Re:Maya – Python Datetimes for Humans by bndr on Sunday December 18, 2016 @04:21AM (#13205029)
How does it differ from Arrow which was made several years ago? [1]

[1] http://crsmithdev.com/arrow/

Re:Maya – Python Datetimes for Humans by crdoconnor on Sunday December 18, 2016 @05:17AM (#13205188)
Or Pendulum. Which is kind of a better arrow: https://github.com/sdispater/pendulum
Re:Maya – Python Datetimes for Humans by djrobstep on Sunday December 18, 2016 @06:46AM (#13205445)
Pendulum is the best of these libraries imho. A couple of rough edges API wise but mostly great and the best feature is the fact that pendulum objects are actual stdlib datetime instances too and so can be used interchangably with code that expects stdlib datetimes.
Re:Maya – Python Datetimes for Humans by daenney on Sunday December 18, 2016 @07:34AM (#13205578)
> the best feature is the fact that pendulum objects are actual stdlib datetime instances too

Exactly this. Makes it so much easier especially when you need to work with other components that only understand the stdlib datetime.

Re:Maya – Python Datetimes for Humans by smegel on Sunday December 18, 2016 @04:30AM (#13205046)
That would be nice to know. Arrow still seems active, and has been consistently so over the last 3 years.

I have a bit of doubt about a time library that defaults to UTC but uses human phrases like "tomorrow". Who thinks about UTC tomorrow?

Re:Maya – Python Datetimes for Humans by kenneth_reitz on Sunday December 18, 2016 @04:40AM (#13205077)
that's why there's `maya.when('yesterday', timezone='US/Eastern')` :)
Re:Maya – Python Datetimes for Humans by Drdrdrq on Sunday December 18, 2016 @06:19AM (#13205373)
That's great, but why this then:

    >>> tomorrow = maya.when('tomorrow') 
    <MayaDT epoch=1481919067.23> 
    >>> tomorrow.slang_date() 
    'tomorrow' 
    >>> tomorrow.slang_time() 
    '23 hours from now'
Huh? Given that we never specified timezone, I would expect 24h (unless DST change happens).

This is actually my biggest gripe with date+time libs. Imho API should always be explicit in what its default TZ is.

EDIT: still, appreciate what you are doing. Requests rule, and there are many other areas (including datetime) that need libs with better APIs. Thumbs up!

Re:Maya – Python Datetimes for Humans by misnome on Sunday December 18, 2016 @07:24AM (#13205545)
Why on earth is 'tomorrow' just +24 (local) hours. I'd expect it to be the next calendar date.
Re:Maya – Python Datetimes for Humans by icebraining on Sunday December 18, 2016 @11:00AM (#13206203)
Next calendar date according to which calendar? Not all places in the world are on the same date, so if you don't indicate the timezone, there's no way to tell what the next calendar date is.
Re:Maya – Python Datetimes for Humans by jibsen on Sunday December 18, 2016 @09:26AM (#13205882)
I suppose due to DST, the same clock time on the next calendar date might not exist or be ambiguous.
Re:Maya – Python Datetimes for Humans by pherq on Sunday December 18, 2016 @10:14AM (#13206050)
Conversely, +24 hours may fall on the same calendar date or two calendar days on from now.

Really, "tomorrow" should be the interval from the beginning of the next calendar date to the end.

Re:Maya – Python Datetimes for Humans by StavrosK on Sunday December 18, 2016 @06:42AM (#13205430)
I'm pretty sure that it's 23 because some time passed between keystrokes, so the delta was 23:59:50, and he only keeps the most significant digit. I had to do this exact thing yesterday for timetaco.com.
Re:Maya – Python Datetimes for Humans by prashnts on Sunday December 18, 2016 @06:47AM (#13205449)
Shouldn't it be immutable? I'd expect this to be a default behaviour.
Re:Maya – Python Datetimes for Humans by amjd on Sunday December 18, 2016 @06:59AM (#13205487)
Not in this case. The entire proposition of slang_time is that it returns human readable time difference with respect to now (i.e., the moment when called).
Re:Maya – Python Datetimes for Humans by paulddraper on Sunday December 18, 2016 @07:51AM (#13205633)
In this case, consistency would imply the immutability of time.
Re:Maya – Python Datetimes for Humans by webmaven on Sunday December 18, 2016 @07:04AM (#13205501)
Shouldn't it round up?
Re:Maya – Python Datetimes for Humans by StavrosK on Sunday December 18, 2016 @07:09AM (#13205510)
If it's 01:00:01, is it two hours?
Re:Maya – Python Datetimes for Humans by Redoubts on Sunday December 18, 2016 @11:29AM (#13206335)
If it's 00:59:50, is it 0 hours?

i have the feeling his natural answer to both questions is no...

Re:Maya – Python Datetimes for Humans by webmaven on Sunday December 18, 2016 @12:00PM (#13206470)
Fine, rounding up fails.

Round to nearest time unit, instead.

Re:Maya – Python Datetimes for Humans by Singletoned on Sunday December 18, 2016 @05:56AM (#13205309)
I have a lot of doubt about a time library that defaults to UTC at all.

Having spent a lot of time dealing with timezones, I have a strong feeling that naive should be the default unless explicitly given a timezone, and your code should blow up when it is given them (or possibly gracefully fail).

Admittedly I haven't had a chance to play with maya as I haven't been able to get it to install.

Re:Maya – Python Datetimes for Humans by daenney on Sunday December 18, 2016 @07:37AM (#13205587)
Naïve is what usually gets everyone into trouble since you have no frame of reference and you need to do all kinds of magic to try and deduce timezones and adapt to it. It also makes it utterly impossible to properly deal with DST changes etc. unless you know that everyone using your system is coming from the same TZ.

I don't like the default of UTC either though. Explicit is better than implicit, so make people always specify a timezone instead which avoids all form of ambiguity.

Re:Maya – Python Datetimes for Humans by jessedhillon on Sunday December 18, 2016 @05:22AM (#13205204)
The unpythonic interface for Arrow stands out sorely in Python codebases.
Re:Maya – Python Datetimes for Humans by DasIch on Sunday December 18, 2016 @05:50AM (#13205288)
I'm not sure I would call Maya particularly pythonic and just like all the other libraries it's API seems to be focused more on fixing issues in other libraries than actually thinking through the problem.