New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

easy-date

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-date - npm Package Compare versions

Comparing version 0.1.1 to 0.9.0

easy-date.min.js

2

bower.json
{
"name": "easy-date",
"main": "easy-date.js",
"version": "0.1.1",
"version": "0.9.0",
"homepage": "https://github.com/melvinsembrano/easy-date",

@@ -6,0 +6,0 @@ "authors": [

(function() {
var EasyDate, days, exports, months;
var EasyDate, days, hours, months, years;

@@ -11,5 +11,3 @@ EasyDate = function(value, type) {

3: "year",
4: "hour",
5: "minute",
6: "second"
4: "hour"
};

@@ -30,2 +28,6 @@ this.value = parseInt(value);

return this._monthsFromNow();
case "year":
return this._yearsFromNow();
case "hour":
return this._hoursFromNow();
default:

@@ -42,2 +44,6 @@ return console.warn("EasyDate: " + this.type + "().fromNow() not yet implemented.");

return this._monthsAgo();
case "year":
return this._yearsAgo();
case "hour":
return this._hoursAgo();
default:

@@ -48,2 +54,12 @@ return console.warn("EasyDate: " + this.type + "().ago() not yet implemented.");

EasyDate.prototype.since = function(date) {
this.now = new Date(date.valueOf());
return this.fromNow();
};
EasyDate.prototype.until = function(date) {
this.now = new Date(date.valueOf());
return this.ago();
};
EasyDate.prototype._daysFromNow = function() {

@@ -77,2 +93,30 @@ var now;

EasyDate.prototype._yearsFromNow = function() {
var now;
now = this.now || new Date();
now.setFullYear(now.getFullYear() + this.value);
return now;
};
EasyDate.prototype._yearsAgo = function() {
var now;
now = this.now || new Date();
now.setFullYear(now.getFullYear() - this.value);
return now;
};
EasyDate.prototype._hoursFromNow = function() {
var now;
now = this.now || new Date();
now.setHours(now.getHours() + this.value);
return now;
};
EasyDate.prototype._hoursAgo = function() {
var now;
now = this.now || new Date();
now.setHours(now.getHours() - this.value);
return now;
};
days = function() {

@@ -86,2 +130,10 @@ return new EasyDate(this, 0);

years = function() {
return new EasyDate(this, 3);
};
hours = function() {
return new EasyDate(this, 4);
};
Number.prototype.day = days;

@@ -95,8 +147,10 @@

if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = EasyDate;
}
}
Number.prototype.years = years;
Number.prototype.year = years;
Number.prototype.hours = hours;
Number.prototype.hour = hours;
}).call(this);

@@ -5,3 +5,3 @@ {

"description": "A Javascript plugin for easy date manipulation.",
"version": "0.1.1",
"version": "0.9.0",
"repository": {

@@ -11,2 +11,4 @@ "type": "git",

},
"author": "Melvin Sembrano <melvinsembrano@gmail.com> (https://github.com/melvinsembrano/easy-date)",
"license": "MIT",
"devDependencies": {

@@ -13,0 +15,0 @@ "grunt": "^0.4.5",

describe('EasyDate', function() {
it('will return the correct date 5 days from now', function() {
var now = new Date();
now.setDate(now.getDate() + 5);
var newDate = 5..days().fromNow();
expect(newDate.getYear()).toBe(newDate.getYear())
expect(newDate.getMonth()).toBe(newDate.getMonth())
expect(newDate.getDate()).toBe(newDate.getDate())
});
it('will return the correct date 5 days ago', function() {
var now = new Date();
now.setDate(now.getDate() - 5);
var newDate = 5..days().ago();
expect(newDate.getYear()).toBe(newDate.getYear())
expect(newDate.getMonth()).toBe(newDate.getMonth())
expect(newDate.getDate()).toBe(newDate.getDate())
});
it('will return the correct date 5 months from now', function() {
var now = new Date();
now.setMonth(now.getMonth() + 5);
var newDate = 5..months().fromNow();
expect(newDate.getYear()).toBe(newDate.getYear())
expect(newDate.getMonth()).toBe(newDate.getMonth())
expect(newDate.getDate()).toBe(newDate.getDate())
});
it('will return the correct date 5 months ago', function() {
var now = new Date();
now.setMonth(now.getMonth() - 5);
var newDate = 5..months().ago();
expect(newDate.getYear()).toBe(newDate.getYear())
expect(newDate.getMonth()).toBe(newDate.getMonth())
expect(newDate.getDate()).toBe(newDate.getDate())
});
it('will return the correct date 5 years from now', function() {
var now = new Date();
now.setFullYear(now.getFullYear() + 5);
var newDate = 5..years().fromNow();
expect(newDate.getYear()).toBe(newDate.getYear())
expect(newDate.getMonth()).toBe(newDate.getMonth())
expect(newDate.getDate()).toBe(newDate.getDate())
});
it('will return the correct date 5 years ago', function() {
var now = new Date();
now.setFullYear(now.getFullYear() - 5);
var newDate = 5..years().ago();
expect(newDate.getYear()).toBe(newDate.getYear())
expect(newDate.getMonth()).toBe(newDate.getMonth())
expect(newDate.getDate()).toBe(newDate.getDate())
});
describe('#days', function() {

@@ -24,2 +86,14 @@ it('can get the number of days', function() {

});
it('#since', function() {
var now = new Date(2015, 3, 10);
expect(3..days().since(now).getDate()).toBe(13);
});
it('#until', function() {
var now = new Date(2015, 3, 10);
var newDate = now.getDate() - 3;
expect(3..days().until(now).getDate()).toBe(newDate);
});
});

@@ -50,5 +124,79 @@

it('#since', function() {
var now = new Date(2015, 3, 10);
expect(3..months().since(now).getMonth()).toBe(6);
});
it('#until', function() {
var now = new Date(2015, 9, 10);
expect(3..months().until(now).getMonth()).toBe(6);
});
});
describe('#years', function() {
it('can get the number of years', function() {
expect(2..years().value).toBe(2);
expect(1..year().type).toBe("year");
});
it('will get the correct grammar', function() {
expect(1..year().toString()).toBe("1 year");
expect(3..years().toString()).toBe("3 years");
expect(5..years().toString()).toBe("5 years");
});
it('#fromNow', function() {
var now = new Date();
expect(3..years().fromNow().getFullYear()).toBe(now.getFullYear() + 3);
});
it('#ago', function() {
var now = new Date();
expect(3..years().ago().getFullYear()).toBe(now.getFullYear() - 3);
});
it('#since', function() {
var now = new Date(2015, 3, 10);
expect(3..years().since(now).getFullYear()).toBe(2018);
});
it('#until', function() {
var now = new Date(2015, 9, 10);
expect(3..years().until(now).getFullYear()).toBe(2012);
});
});
describe('#hours', function() {
it('can get the number of hours', function() {
expect(2..hours().value).toBe(2);
expect(1..hour().type).toBe("hour");
});
it('will get the correct grammar', function() {
expect(1..hour().toString()).toBe("1 hour");
expect(3..hours().toString()).toBe("3 hours");
expect(5..hours().toString()).toBe("5 hours");
});
it('#fromNow', function() {
var now = new Date();
expect(3..hours().fromNow().getHours()).toBe(now.getHours() + 3);
});
it('#ago', function() {
var now = new Date();
expect(3..hours().ago().getHours()).toBe(now.getHours() - 3);
});
it('#since', function() {
var now = new Date(2015, 3, 10, 12);
expect(3..hours().since(now).getHours()).toBe(15);
});
it('#until', function() {
var now = new Date(2015, 9, 10, 12);
expect(3..hours().until(now).getHours()).toBe(9);
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc