kuzmoyev / beautiful-date

Simple and beautiful way to create date and datetime objects in Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rails like syntax possible?

FardinAhsan146 opened this issue · comments

In Rails you can call datetime methods on integers that return datetime objects such as 1.month.from_now.

Would the package benefit from some addition like that? Perhaps add an option to enable/disable rails like datetime monkeypatching.

That looks interesting. Unfortunately this specifically isn't possible (to my knowledge). But something like

1 * months.from_now

is possible. Could you please share a list of available methods (or how these are called in Rails) like that? I'll think about implementing these in my free time.

Great suggestion! Thanks

Yeah, I think 1 * month.from_now is more intuitive. The first time I saw the Rails syntax was jarring.

@FardinAhsan146 I've added the implementation in #31. It still needs the documentation update and I'll push it to Pypi. If you're interested, feel free to check it and share your thoughts in the PR.

Thanks again for the idea!

Looks good to me. Thanks for the fast implementation.

I have a major time series project coming up at work that is going to be date manipulation all the way down, this is going to make it slightly easier to work with.

It's in v2.3.0