Giter Site home page Giter Site logo

Comments (3)

YBadiss avatar YBadiss commented on May 21, 2024 1

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.

sdispater avatar sdispater commented on May 21, 2024

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.

JelteF avatar JelteF commented on May 21, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.