Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "date-diff", | ||
"main": "date-diff.js", | ||
"version": "0.1.3", | ||
"version": "0.2.1", | ||
"homepage": "https://github.com/melvinsembrano/date-diff", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.0 | ||
// Generated by CoffeeScript 2.3.1 | ||
(function() { | ||
@@ -54,7 +54,5 @@ /* | ||
DateDiff.prototype.years = function() { | ||
var eom, ret; | ||
var ret; | ||
ret = this.date1.getFullYear() - this.date2.getFullYear(); | ||
ret += (this.date1.getMonth() - this.date2.getMonth()) / 12; | ||
eom = this.endOfMonth(this.date2).getDate(); | ||
ret += (this.date1.getDate() / eom) - (this.date2.getDate() / eom); | ||
ret += (this.dayOfYear(this.date1) - this.dayOfYear(this.date2)) / this.daysInYear(this.date2); | ||
return this._roundIt(ret); | ||
@@ -71,2 +69,14 @@ }; | ||
DateDiff.prototype.beginOfYear = function(date) { | ||
return new Date(date.getFullYear(), 0, 0); | ||
}; | ||
DateDiff.prototype.dayOfYear = function(date) { | ||
return (date - this.beginOfYear(date)) / divisors.days; | ||
}; | ||
DateDiff.prototype.daysInYear = function(date) { | ||
return (this.endOfYear(date) - this.beginOfYear(date)) / divisors.days; | ||
}; | ||
DateDiff.prototype._roundIt = function(v) { | ||
@@ -73,0 +83,0 @@ return parseFloat(v.toFixed(1)); |
/*! | ||
date-diff 0.1.3 | ||
date-diff 0.2.1 | ||
Description: DateDiff is a minimalized Javascript date arithmetic extension. | ||
Author: Melvin Sembrano <melvinsembrano@gmail.com> (https://github.com/melvinsembrano/date-diff) | ||
*/ | ||
(function(){var a,b;a=function(a,b){this.date1=a,this.date2=b,this.difference=Math.floor(a-b)},b={days:864e5,hours:36e5,minutes:6e4,seconds:1e3},a.prototype.weeks=function(){return this._roundIt(this.days()/7)},a.prototype.days=function(){return this._roundIt(this.difference/b.days)},a.prototype.hours=function(){return this._roundIt(this.difference/b.hours)},a.prototype.minutes=function(){return this._roundIt(this.difference/b.minutes)},a.prototype.seconds=function(){return this._roundIt(this.difference/b.seconds)},a.prototype.months=function(){var a,b;return b=12*(this.date1.getFullYear()-this.date2.getFullYear()),b+=this.date1.getMonth()-this.date2.getMonth(),a=this.endOfMonth(this.date2).getDate(),b+=this.date1.getDate()/a-this.date2.getDate()/a,this._roundIt(b)},a.prototype.years=function(){var a,b;return b=this.date1.getFullYear()-this.date2.getFullYear(),b+=(this.date1.getMonth()-this.date2.getMonth())/12,a=this.endOfMonth(this.date2).getDate(),b+=this.date1.getDate()/a-this.date2.getDate()/a,this._roundIt(b)},a.prototype.endOfMonth=function(a){return new Date(a.getFullYear(),a.getMonth()+1,0)},a.prototype.endOfYear=function(a){return new Date(a.getFullYear()+1,0,0)},a.prototype._roundIt=function(a){return parseFloat(a.toFixed(1))},Date.diff=function(b,c){return new a(b,c)},this.DateDiff=a,"undefined"!=typeof module&&(module.exports=a)}).call(this); | ||
(function(){var n,e;e={days:864e5,hours:36e5,minutes:6e4,seconds:1e3},(n=function(t,e){this.date1=t,this.date2=e,this.difference=Math.floor(t-e)}).prototype.weeks=function(){return this._roundIt(this.days()/7)},n.prototype.days=function(){return this._roundIt(this.difference/e.days)},n.prototype.hours=function(){return this._roundIt(this.difference/e.hours)},n.prototype.minutes=function(){return this._roundIt(this.difference/e.minutes)},n.prototype.seconds=function(){return this._roundIt(this.difference/e.seconds)},n.prototype.months=function(){var t,e;return e=12*(this.date1.getFullYear()-this.date2.getFullYear()),e+=this.date1.getMonth()-this.date2.getMonth(),t=this.endOfMonth(this.date2).getDate(),e+=this.date1.getDate()/t-this.date2.getDate()/t,this._roundIt(e)},n.prototype.years=function(){var t;return t=this.date1.getFullYear()-this.date2.getFullYear(),t+=(this.dayOfYear(this.date1)-this.dayOfYear(this.date2))/this.daysInYear(this.date2),this._roundIt(t)},n.prototype.endOfMonth=function(t){return new Date(t.getFullYear(),t.getMonth()+1,0)},n.prototype.endOfYear=function(t){return new Date(t.getFullYear()+1,0,0)},n.prototype.beginOfYear=function(t){return new Date(t.getFullYear(),0,0)},n.prototype.dayOfYear=function(t){return(t-this.beginOfYear(t))/e.days},n.prototype.daysInYear=function(t){return(this.endOfYear(t)-this.beginOfYear(t))/e.days},n.prototype._roundIt=function(t){return parseFloat(t.toFixed(1))},Date.diff=function(t,e){return new n(t,e)},this.DateDiff=n,"undefined"!=typeof module&&(module.exports=n)}).call(this); |
@@ -5,3 +5,3 @@ { | ||
"description": "DateDiff is a minimalized Javascript date arithmetic extension.", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "DateDiff", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19395
248