Comments (3)
what would be the advantage over doing
tomorrow_in_paris = now_in_paris.add(days=1)
next_week_in_paris = now_in_paris.add(weeks=1)
as described in the readme?
If you want to use the __add__
operator directly or pass in the value to add, couldn't you do something like
from pendulum import Interval
now_in_paris = pm.now('Europe/Paris')
tomorrow_in_paris = now_in_paris + Interval(days=1)
next_week_in_paris = now_in_paris + Interval(weeks=1)
from pendulum.
Even though I can see the appeal of Ruby's Time.now + 1.day
, I don't think it brings that much over the existing API, except saving a few characters, and it loses the ability to create your durations programatically with a dict which I find useful.
from pendulum.
@YBadiss Yes, it's not that these two methods do not work. It's simply that this method would be shorter and IMHO still easy to read and understand. Especially when subtracting something it would be shorter as subtract
is quite long.
Your second solution is also what I meant as the way to implement it, simply doing something like this (with the s suffixed names also added):
week = weeks = Interval(weeks=1)
day = days = Interval(days=1)
seconds = seconds = Interval(seconds=1)
...
@sdispater I'm not proposing that we should replace the existing API, just add this very simple feature so it can be quickly used in cases where it would be useful. Isn't saving characters partly why this library is created in the first place?
from pendulum.
Related Issues (20)
- pendulum.now() type hint doesn't allow datetime.timezone
- Unable to build pendulum for 32bit HOT 10
- Segmentation fault at import when running 3.0.0 under Docker Alpine linux
- Arithmetic overflow during the compilation of the Rust code for the "_pendulum" library. HOT 1
- Allow formatting of `in_words`
- dst_rule not implemented in 3.x? Has it in documentation but examples don't work. HOT 3
- in_months() returns wrong values in some cases in January to February HOT 1
- pendulum PanicException on FreeBSD 14 HOT 4
- [Feature Request] Add strict mode for from_format()
- backports-zoneinfo does not compile on 3.10, and hard to package (pyinstaller, zipapp,...) HOT 3
- Bug / regression: Unable to parse string '031' with 'DDDD' format using Pendulum 3.0.0
- Regression - Inconsistent DBAPI serialization of pendulum datetimes
- Duration division, multiplication and mod broken for month lengths. HOT 1
- Default datetime string format changed in 3.0 release HOT 2
- Security issue or bug with pipenv ? HOT 1
- to_iso8601_string
- instance() fails for datetimes with pytz.FixedOffsets
- "import pendulum" causes unwanted import of pytest (presence of pytest in sys.modules often used to control Python behaviour) HOT 1
- MMM is not case-insensitive like Java
- If you have the /etc/timezone file set to a timezone string, pendulum.UTC has that timezone's utcoffset instead of None HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pendulum.