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

time

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

time - npm Package Compare versions

Comparing version 0.9.2 to 0.10.0

132

index.js

@@ -316,41 +316,65 @@ /**

this.setAllDateFields = function setAllDateFields(y,mo,d) {
zoneInfo.year = y - 1900;
zoneInfo.month = mo;
zoneInfo.dayOfMonth = d;
return mktime.call(this);
return this.setFullYear(y,mo,d);
}
// Sets the day of the month (from 1-31) in the current timezone
this.setDate = function setDate(v) {
zoneInfo.dayOfMonth = v;
this.setDate = function setDate(d) {
zoneInfo.dayOfMonth = d;
return mktime.call(this);
}
// Sets the year (four digits) in the current timezone
this.setFullYear = function setFullYear(v) {
zoneInfo.year = v - 1900;
this.setFullYear = function setFullYear(y,mo,d) {
zoneInfo.year = y - 1900;
if(arguments.length > 1)
zoneInfo.month = mo;
if(arguments.length > 2)
zoneInfo.dayOfMonth = d;
return mktime.call(this);
}
// Sets the hour (from 0-23) in the current timezone
this.setHours = function setHours(v) {
zoneInfo.hours = v;
return mktime.call(this);
this.setHours = function setHours(h,m,s,ms) {
zoneInfo.hours = h;
if(arguments.length > 1)
zoneInfo.minutes = m;
if(arguments.length > 2)
zoneInfo.seconds = s;
if(arguments.length > 3) {
mktime.call(this);
var diff = ms - this.getMilliseconds();
return this.setTime(this.getTime() + diff);
} else
return mktime.call(this);
}
// Sets the milliseconds (from 0-999) in the current timezone
this.setMilliseconds = function setMilliseconds(v) {
var diff = v - this.getMilliseconds();
this.setMilliseconds = function setMilliseconds(ms) {
var diff = ms - this.getMilliseconds();
return this.setTime(this.getTime() + diff);
}
// Set the minutes (from 0-59) in the current timezone
this.setMinutes = function setMinutes(v) {
zoneInfo.minutes = v;
return mktime.call(this);
this.setMinutes = function setMinutes(m,s,ms) {
zoneInfo.minutes = m;
if(arguments.length > 1)
zoneInfo.seconds = s;
if(arguments.length > 2) {
mktime.call(this);
var diff = ms - this.getMilliseconds();
return this.setTime(this.getTime() + diff);
} else
return mktime.call(this);
}
// Sets the month (from 0-11) in the current timezone
this.setMonth = function setMonth(v) {
zoneInfo.month = v;
this.setMonth = function setMonth(mo,d) {
zoneInfo.month = mo;
if(arguments.length > 1)
zoneInfo.dayOfMonth = d;
return mktime.call(this);
}
// Sets the seconds (from 0-59) in the current timezone
this.setSeconds = function setSeconds(v) {
zoneInfo.seconds = v;
return mktime.call(this);
this.setSeconds = function setSeconds(s,ms) {
zoneInfo.seconds = s;
if(arguments.length > 1) {
mktime.call(this);
var diff = ms - this.getMilliseconds();
return this.setTime(this.getTime() + diff);
} else
return mktime.call(this);
}

@@ -367,4 +391,4 @@ // Sets a date and time by adding or subtracting a specified number of

// Sets the day of the month, according to universal time (from 1-31)
this.setUTCDate = function setUTCDate(v) {
var rtn = _Date.prototype.setUTCDate.call(this, v);
this.setUTCDate = function setUTCDate(d) {
var rtn = _Date.prototype.setUTCDate.call(this, d);
reset.call(this);

@@ -374,4 +398,12 @@ return rtn;

// Sets the year, according to universal time (four digits)
this.setUTCFullYear = function setUTCFullYear(v) {
var rtn = _Date.prototype.setUTCFullYear.call(this, v);
this.setUTCFullYear = function setUTCFullYear(y,mo,d) {
var rtn;
switch(arguments.length) {
case 1:
rtn = _Date.prototype.setUTCFullYear.call(this, y); break;
case 2:
rtn = _Date.prototype.setUTCFullYear.call(this, y,mo); break;
case 3:
rtn = _Date.prototype.setUTCFullYear.call(this, y,mo,d); break;
}
reset.call(this);

@@ -381,4 +413,14 @@ return rtn;

// Sets the hour, according to universal time (from 0-23)
this.setUTCHours = function setUTCHours(v) {
var rtn = _Date.prototype.setUTCHours.call(this, v);
this.setUTCHours = function setUTCHours(h,m,s,ms) {
var rtn;
switch(arguments.length) {
case 1:
rtn = _Date.prototype.setUTCHours.call(this, h); break;
case 2:
rtn = _Date.prototype.setUTCHours.call(this, h,m); break;
case 3:
rtn = _Date.prototype.setUTCHours.call(this, h,m,s); break;
case 4:
rtn = _Date.prototype.setUTCHours.call(this, h,m,s,ms); break;
}
reset.call(this);

@@ -388,4 +430,4 @@ return rtn;

// Sets the milliseconds, according to universal time (from 0-999)
this.setUTCMilliseconds = function setUTCMillseconds(v) {
var rtn = _Date.prototype.setUTCMilliseconds.call(this, v);
this.setUTCMilliseconds = function setUTCMillseconds(ms) {
var rtn = _Date.prototype.setUTCMilliseconds.call(this, ms);
reset.call(this);

@@ -395,4 +437,12 @@ return rtn;

// Set the minutes, according to universal time (from 0-59)
this.setUTCMinutes = function setUTCMinutes(v) {
var rtn = _Date.prototype.setUTCMinutes.call(this, v);
this.setUTCMinutes = function setUTCMinutes(m,s,ms) {
var rtn;
switch(arguments.length) {
case 1:
rtn = _Date.prototype.setUTCMinutes.call(this, m); break;
case 2:
rtn = _Date.prototype.setUTCMinutes.call(this, m,s); break;
case 3:
rtn = _Date.prototype.setUTCMinutes.call(this, m,s,ms); break;
}
reset.call(this);

@@ -402,4 +452,10 @@ return rtn;

// Sets the month, according to universal time (from 0-11)
this.setUTCMonth = function setUTCMonth(v) {
var rtn = _Date.prototype.setUTCMonth.call(this, v);
this.setUTCMonth = function setUTCMonth(mo,d) {
var rtn;
switch(arguments.length) {
case 1:
rtn = _Date.prototype.setUTCMonth.call(this, mo); break;
case 2:
rtn = _Date.prototype.setUTCMonth.call(this, mo,d); break;
}
reset.call(this);

@@ -409,4 +465,10 @@ return rtn;

// Set the seconds, according to universal time (from 0-59)
this.setUTCSeconds = function setUTCSeconds(v) {
var rtn = _Date.prototype.setUTCSeconds.call(this, v);
this.setUTCSeconds = function setUTCSeconds(s,ms) {
var rtn;
switch(arguments.length) {
case 1:
rtn = _Date.prototype.setUTCSeconds.call(this, s); break;
case 2:
rtn = _Date.prototype.setUTCSeconds.call(this, s,ms); break;
}
reset.call(this);

@@ -413,0 +475,0 @@ return rtn;

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

"keywords": ["date", "time", "time.h", "timezone", "setTimezone", "getTimezone"],
"version": "0.9.2",
"version": "0.10.0",
"repository": {

@@ -25,7 +25,8 @@ "type": "git",

, "debug": "*"
, "nan": "~0.4.4"
},
"devDependencies": {
"mocha": "*"
, "should": "*"
, "should": "~0.6.3"
}
}

@@ -60,2 +60,48 @@ var should = require('should')

it('should accept js1.3 extended set* arguments', function() {
var d = new time.Date(2000, 1, 2, 3, 4, 5, 6, 'America/Chicago');
d.setFullYear(2001, 2, 3);
d.getTime().should.equal(983610245006);
d.setFullYear(2002, 3);
d.getTime().should.equal(1017824645006);
d.setMonth(4, 5);
d.getTime().should.equal(1020585845006);
d.setHours(4, 5, 6, 7);
d.getTime().should.equal(1020589506007);
d.setHours(5, 6, 7);
d.getTime().should.equal(1020593167007);
d.setHours(6, 7);
d.getTime().should.equal(1020596827007);
d.setMinutes(8, 9, 10);
d.getTime().should.equal(1020596889010);
d.setMinutes(9, 10);
d.getTime().should.equal(1020596950010);
d.setSeconds(11, 12);
d.getTime().should.equal(1020596951012);
})
it('should accept js1.3 extended setUTC* arguments', function() {
var d = new time.Date(2000, 1, 2, 3, 4, 5, 6, 'America/Chicago');
d.setUTCFullYear(2001, 2, 3);
d.getTime().should.equal(983610245006);
d.setUTCFullYear(2002, 3);
d.getTime().should.equal(1017824645006);
d.setUTCMonth(4, 5);
d.getTime().should.equal(1020589445006);
d.setUTCHours(4, 5, 6, 7);
d.getTime().should.equal(1020571506007);
d.setUTCHours(5, 6, 7);
d.getTime().should.equal(1020575167007);
d.setUTCHours(6, 7);
d.getTime().should.equal(1020578827007);
d.setUTCMinutes(8, 9, 10);
d.getTime().should.equal(1020578889010);
d.setUTCMinutes(9, 10);
d.getTime().should.equal(1020578950010);
d.setUTCSeconds(11, 12);
d.getTime().should.equal(1020578951012);
})
describe('#setTimezone()', function () {

@@ -62,0 +108,0 @@

Sorry, the diff of this file is not supported yet

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