Coder Social home page Coder Social logo

Comments (10)

lancecarlson avatar lancecarlson commented on July 17, 2024

Looking at the yesterday implementation, it looks like there is certainly support for it but there is no documentation for supplying .add with negative values. Maybe add should be renamed or subtract methods added with the negative behavior?

from date-utils.

JerrySievert avatar JerrySievert commented on July 17, 2024

renaming add would be a breaking change, but yes, there is (undocumented) support for negative numbers.

from date-utils.

lancecarlson avatar lancecarlson commented on July 17, 2024

Perhaps it should be documented ? If not, maybe have subtract functions?

from date-utils.

JerrySievert avatar JerrySievert commented on July 17, 2024

Agreed! I'll try to get it documented shortly. As an aside, documentation related pull requests are always welcome! :)

from date-utils.

lancecarlson avatar lancecarlson commented on July 17, 2024

Well, I would've but I also wanted to make sure you would rather have it documented then have additional methods. If I have time tomorrow (and you haven't documented it already) I will submit a pull request! =D

from date-utils.

JerrySievert avatar JerrySievert commented on July 17, 2024

that would be awesome! the library is growing fairly large as-is, which means either a) a ton of refactoring, or b) keep the number of methods low.

a refactoring with a ton more documentation would be nice, which would allow for more cleanliness and still allow for a more full api.

from date-utils.

bebraw avatar bebraw commented on July 17, 2024

If you decide to refactor it (v2?), find a common name that works for addition and subtraction. It would be nice to have a non-mutating way to deal with dates by the way? Consider the following example:

var now = new Date();
var twoMonthsAgo = now.modify({months: -2});
var duration = twoMonthsAgo.to(now); // {months: -2}

duration output depends on order. It is also possible to pass the output to modify so the API is pluggable this way.

Maybe my use cases are different than others and there are likely reasons for the mutating API (OOP after all :) ). I would find this sort of thing very cool, though.

from date-utils.

JerrySievert avatar JerrySievert commented on July 17, 2024

v2. wow. there should probably be an issue that can help hash out goals for v2.

from date-utils.

bebraw avatar bebraw commented on July 17, 2024

@JerrySievert Can you start one?

from date-utils.

JerrySievert avatar JerrySievert commented on July 17, 2024

remove added, closing this!

from date-utils.

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.