Live data from Hacker News

Maya – Python Datetimes for Humans

kennethreitz.org

101–110 of 180 posts

Re: Maya – Python Datetimes for Humans

#101

I wish Kenneth would have contributed to an existed project for once. Arrow and pendulum (my current favorite) have a very decent API. The later one is especially well tested for the numerous corner cases of date handling, which I doubt Kenneth got right on first try. For request, a full rewrite made sense because urllib sucked so much and we had no good alternatives. But for date time, alternative exists and they ar…

Do either of those libraries have an equivalent to the 'slang time' feature?

Re: Maya – Python Datetimes for Humans

#102
i dont trust any piece of software that has all these made-up, unrelated, non-reflecting names. I mean come on, arrow, maya ? the main challenge about software engineering is correct naming. If you fail there you pretty much fail in the rest. Same goes for actually builtin name, "datetime". There is no such thing in real life as datetime. There is date and there is time. They are very separate notions and the root of the problem IMO is in trying to pile them together.

Re: Maya – Python Datetimes for Humans

#103
post #53
post #38

Earlier quoted context omitted.

That's great, but why this then: >>> tomorrow = maya.when('tomorrow') >>> 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…

Why on earth is 'tomorrow' just +24 (local) hours. I'd expect it to be the next calendar date.

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

#104
post #101

I wish Kenneth would have contributed to an existed project for once. Arrow and pendulum (my current favorite) have a very decent API. The later one is especially well tested for the numerous corner cases of date handling, which I doubt Kenneth got right on first try. For request, a full rewrite made sense because urllib sucked so much and we had no good alternatives. But for date time, alternative exists and they ar…

Do either of those libraries have an equivalent to the 'slang time' feature?

Arrow does, and have more translations.

Re: Maya – Python Datetimes for Humans

#105
I think its fascinating that the community has no consensus about a datetime library.

A lot of Python is really solved. We don't argue about using requests (a not-coincidental example). If you're using Python, and you need to deal with http, you use requests. Everyone knows this.

There are basically 3 platforms for web frameworks. Flask, Pyramid, and Django. Maybe we're a little more dissolute than C# or Ruby folks, but that's pretty impressive considering how much we Python people like to roll our own.

The fact that there is real disagreement about this among ourselves about this particular issue says to me that this is more about the difficulty of the problem than it is anything else.

Re: Maya – Python Datetimes for Humans

#106

Earlier quoted context omitted.

I think the recommendation still holds. You want a meeting at 1100 local time. Meeting is stored for that time in UTC, on the correct date (before Samoa changed, we all understood what date you meant) Samoa changes the rules. The calendar doesn't change. This stuff is mind-bending, so I could be missing something, but a more detailed walk through your mental debugger might clarify.

Classic counter example: storing business hours. If the store/exchange opens at 8:00AM every weekday in Somethingania/Foocity, you want to store 8:00 and the name/reference of the timezone. Because the store/exchange will still open at 8:00AM local time, even across DST, government-mandated timezone changes etc (largely, I'm sure there are exceptions but for stock exchanges there definitely aren't). School times, tim…

[deleted]

Re: Maya – Python Datetimes for Humans

#107
post #23

Awesome! Timekeeping is hard and I'm glad we now have one more tool do deal with it. One thing that is bothering me is that when you ask for `maya.when('tomorrow')`, or give only a date, you get back a timestamp with millisecond precision, representing 00:00 of that day. I understand this simplifies the implementation, but shouldn't `tomorrow` be a range , from 00:00 to 23:59? Treating imprecise dates as ranges would…

Maybe `when` should be renamed or an alias to `at` and add an `in` method to make it more explicit.

Re: Maya – Python Datetimes for Humans

#108
post #96

Earlier quoted context omitted.

Arguably bringing multiple dependencies under one roof, with a nice, human-readable interface, is exactly what the value is here. This SO answer from Pandas lead Wes Mckinney says it better than anything I could comment. Python datetime/timestamp management: "Welcome to Hell" http://stackoverflow.com/questions/13703720/converting-betwe... I run batch and real time financial feeds into Python from multiple sources, in…

I think there are two separate issues here. One thing is that some libraries bring their own not-really-different-just-different-enough-to-break-things date/time types to the table. That can be worked out over time, not that big of a problem, just inconvenient. The other is that I've grown to think that the abstraction commonly used, seeing date/time as something like (year, month, day, hour, minute, second, subsecon…

agreed and well put. Don't even get me started on R's inconsistencies between for example, base, and zoo/xts POSIXlt, POSIXct and as.date, when it comes to summer time changes. One lib counts 6 days the other counts 7! Because they've got different bugs. It's a mess precisely because each library has its own bugs for many of the edge cases you mention. Personally, because leap seconds are not important to me, I've gone with Unix epoch as the base "universal language" to/from which I convert everything. Conveniently it talks JS easily too. And I do everything UTC. Still, for example, it's a complete and utter nightmare when, for example, needing to bring the 30 different equity market indices I cover's opening and closing times around the world, into a single and consistent time framework, what with each country's weird different rules and daylight savings times, which, to make it even worse, have changed multiple (badly documented) times over the years, making historic analysis an exercise in True Pain. Finally, to meet Satan himself, try getting into fixed income market daycount conventions....

Re: Maya – Python Datetimes for Humans

#110

I wonder if the naming isn't a bit unfortunate, seeing that Maya is one of the major 3d packages out there and googling for Maya and Python will almost always lead there (also, not sure whether Autodesk might object...)

MayaTime would be a responsible name for this project. Brand Name + Hint about is functionality.

Like "JodaTime" and "Golang"

Post reply on HN