Comments (10)
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.
renaming add
would be a breaking change, but yes, there is (undocumented) support for negative numbers.
from date-utils.
Perhaps it should be documented ? If not, maybe have subtract functions?
from date-utils.
Agreed! I'll try to get it documented shortly. As an aside, documentation related pull requests are always welcome! :)
from date-utils.
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.
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.
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.
v2. wow. there should probably be an issue that can help hash out goals for v2.
from date-utils.
@JerrySievert Can you start one?
from date-utils.
remove
added, closing this!
from date-utils.
Related Issues (20)
- How do you feel about... ? HOT 1
- d.getMonthsBetween(date); HOT 28
- Version 2 Feature Discussion HOT 14
- Add `remove` to README
- error in the parsing of the weekday HOT 1
- getDaysBetween returns wrong number HOT 3
- No bower versions HOT 3
- How to set one special Date() object? HOT 1
- Browser support? HOT 2
- Number of Days between HOT 3
- site.flatly.css contains a broken import according to cssmin
- Property 'jui' redefine problem HOT 1
- Official typescript typings HOT 3
- getMonthsBetween inconsitency HOT 7
- Method getMonthAbbrNameFromNumber doesn't exists
- SCRIPT1046: Multiple definitions of a property not allowed in strict mode
- Cannot find module 'date-utils' HOT 2
- Function add/addMonths compute error HOT 3
- on node v10,Do I still need this polyfill ?
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 date-utils.