Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chaining-date

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chaining-date - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

2

bench/package.json

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

"moment": "^2.24.0",
"date-fns": "^2.7.0",
"date-fns": "^2.8.1",
"dayjs": "^1.8.17"
}
}

@@ -1,1 +0,1 @@

var ChainingDate=function(){var t=["Year","Month","Date","Day","Hours","Minutes","Seconds","Milliseconds"];var n=Date;function e(t){this.date="number"==typeof t?new n(t):"string"==typeof t?new n(n.parse(t)):t||new n}return function(n){for(var e=t.length;e--;)!function(t){var e="add"+t,r="get"+t,i="set"+t;n[r]=function(){return this.date[r]()},n[i]=function(t){return this.date[i](t),this},n[e]=function(t){return this[i](this[r]()+t),this}}(t[e]);n.getYear=function(){return this.date.getFullYear()},n.setYear=function(t){return this.date.setFullYear(t),this},n.getMonth=function(){return this.date.getMonth()+1},n.setMonth=function(t){return this.date.setMonth(t-1),this}}(e.prototype),e}();
var ChainingDate=function(){var t=["Time","Year","Month","Date","Day","Hours","Minutes","Seconds","Milliseconds"];var n=Date;function e(t){this.date="number"==typeof t?new n(t):"string"==typeof t?new n(n.parse(t)):t||new n}return function(n){for(var e=t.length;e--;)!function(t){var e="add"+t,i="get"+t,r="set"+t;n[i]=function(){return this.date[i]()},n[r]=function(t){return this.date[r](t),this},n[e]=function(t){return this[r](this[i]()+t),this}}(t[e]);n.getYear=function(){return this.date.getFullYear()},n.getMonth=function(){return this.date.getMonth()+1},n.setMonth=function(t){return this.date.setMonth(t-1),this}}(e.prototype),e}();
/**
* @author TroyTae
* @version 0.5.1
* @version 0.5.2
* @name chaining-date

@@ -9,2 +9,3 @@ */

var DateMethods = [
'Time',
'Year',

@@ -45,6 +46,2 @@ 'Month',

};
prototype.setYear = function(value) {
this.date.setFullYear(value);
return this;
};
prototype.getMonth = function() {

@@ -51,0 +48,0 @@ return this.date.getMonth() + 1;

{
"name": "chaining-date",
"version": "0.5.1",
"version": "0.5.2",
"description": "A tiny module for using Date with chaining ⏱",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -13,2 +13,3 @@ var DateFormat = {

var DateMethods = [
'Time',
'Year',

@@ -15,0 +16,0 @@ 'Month',

@@ -28,6 +28,2 @@ import {DateMethods} from './constants';

};
prototype.setYear = function(value) {
this.date.setFullYear(value);
return this;
};
prototype.getMonth = function() {

@@ -34,0 +30,0 @@ return this.date.getMonth() + 1;

@@ -6,14 +6,19 @@ const ChainingDate = require('../dist/index');

const date = 21;
const hours = 2;
const minutes = 37;
const seconds = 48;
const milliseconds = 192;
test('getter', () => {
const date = new Date();
const today = new Date();
const chainingDate = new ChainingDate();
expect(chainingDate.getYear()).toBe(date.getFullYear());
expect(chainingDate.getMonth()).toBe(date.getMonth() + 1);
expect(chainingDate.getDate()).toBe(date.getDate());
expect(chainingDate.getDay()).toBe(date.getDay());
expect(chainingDate.getHours()).toBe(date.getHours());
expect(chainingDate.getMinutes()).toBe(date.getMinutes());
expect(chainingDate.getSeconds()).toBe(date.getSeconds());
expect(chainingDate.getMilliseconds()).toBe(date.getMilliseconds());
expect(chainingDate.getTime()).toBe(today.getTime());
expect(chainingDate.getYear()).toBe(today.getFullYear());
expect(chainingDate.getMonth()).toBe(today.getMonth() + 1);
expect(chainingDate.getDate()).toBe(today.getDate());
expect(chainingDate.getDay()).toBe(today.getDay());
expect(chainingDate.getHours()).toBe(today.getHours());
expect(chainingDate.getMinutes()).toBe(today.getMinutes());
expect(chainingDate.getSeconds()).toBe(today.getSeconds());
expect(chainingDate.getMilliseconds()).toBe(today.getMilliseconds());
});

@@ -23,12 +28,25 @@

const chainingDate = new ChainingDate();
expect(chainingDate.setTime(Date.now()).getTime()).toBe(Date.now());
expect(chainingDate.setYear(year).getYear()).toBe(year);
expect(chainingDate.setMonth(month).getMonth()).toBe(month);
expect(chainingDate.setDate(date).getDate()).toBe(date);
// expect(chainingDate.setDay(date).getDate()).toBe(/**/);
expect(chainingDate.setHours(hours).getHours()).toBe(hours);
expect(chainingDate.setMinutes(minutes).getMinutes()).toBe(minutes);
expect(chainingDate.setSeconds(seconds).getSeconds()).toBe(seconds);
expect(chainingDate.setMilliseconds(milliseconds).getMilliseconds()).toBe(milliseconds);
});
test('adder', () => {
const today = new Date();
const chainingDate = new ChainingDate();
expect(chainingDate.setTime(today.getTime()).addTime(156473).getTime()).toBe(today.getTime() + 156473);
expect(chainingDate.setYear(year).addYear(3).getYear()).toBe(year + 3);
expect(chainingDate.setMonth(month).addMonth(1).getMonth()).toBe(month + 1);
expect(chainingDate.setDate(date).addDate(-11).getDate()).toBe(date - 11);
// expect(chainingDate.setDay(date).addDay(1).getDate()).toBe(/**/);
expect(chainingDate.setHours(hours).addHours(8).getHours()).toBe(hours + 8);
expect(chainingDate.setMinutes(minutes).addMinutes(-2).getMinutes()).toBe(minutes - 2);
expect(chainingDate.setSeconds(seconds).addSeconds(2).getSeconds()).toBe(seconds + 2);
expect(chainingDate.setMilliseconds(milliseconds).addMilliseconds(108).getMilliseconds()).toBe(milliseconds + 108);
});
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