Comments (7)
That's a darned good question.
from date-utils.
it was actually done 6 days ago, but i just found that i hadn't hit "comment" on the comment.
from date-utils.
i'll try to dig into this soon - i was working on another project most of the weekend, and ran out of time.
from date-utils.
Thanks Jerry :)
--
Sean Hill
[email protected]
www.seanhill.info
On April 18, 2016 at 8:57:59 AM, Jerry Sievert ([email protected]) wrote:
i'll try to dig into this soon - i was working on another project most of the weekend, and ran out of time.
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
from date-utils.
it looks like this method could be rewritten fairly easily to be a lot more accurate.
i'll take a quick pass at it this evening, and if i get it working will get it updated.
might not be until this weekend until it's fixed, depends on how much free time i'm able to get.
from date-utils.
i rewrote getMonthsBetween
to be a lot more precise than what was there:
var daysDiff = Math.abs(((+this) / (86400 * 1000)) - ((+date) / (86400 * 1000)));
var start = new Date((+date) < (+this) ? (+date) : (+this));
var end = new Date((date) > (+this) ? (+date) : (+this));
var months = 0;
while (+start < +end) {
months++;
start = start.addMonths(1);
}
var days = Math.abs(((+start) / (86400 * 1000)) - ((+end) / (86400 * 1000)));
return months - (days / 31);
i've published a new release.
from date-utils.
Thanks Jerry!
from date-utils.
Related Issues (20)
- How do you feel about... ? HOT 1
- subtract instance methods HOT 10
- 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
- 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.