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

chronoshift

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chronoshift - npm Package Compare versions

Comparing version 0.6.6 to 0.6.7

114

build/chronoshift.js

@@ -7,53 +7,2 @@ 'use strict';

var check;
var Timezone = (function () {
function Timezone(timezone) {
if (typeof timezone !== 'string') {
throw new TypeError("timezone description must be a string");
}
if (timezone !== 'Etc/UTC' && !moment.tz.zone(timezone)) {
throw new Error("timezone '" + timezone + "' does not exist");
}
this.timezone = timezone;
}
Timezone.isTimezone = function (candidate) {
return candidate instanceof Timezone;
};
Timezone.formatDateWithTimezone = function (d, timezone) {
var str;
if (timezone && !timezone.isUTC()) {
str = moment.tz(d, timezone.toString()).format('YYYY-MM-DDTHH:mm:ss.SSSZ');
}
else {
str = d.toISOString();
}
return str.replace('.000', '');
};
Timezone.fromJS = function (spec) {
return new Timezone(spec);
};
Timezone.prototype.valueOf = function () {
return this.timezone;
};
Timezone.prototype.toJS = function () {
return this.timezone;
};
Timezone.prototype.toJSON = function () {
return this.timezone;
};
Timezone.prototype.toString = function () {
return this.timezone;
};
Timezone.prototype.equals = function (other) {
return Timezone.isTimezone(other) &&
this.timezone === other.timezone;
};
Timezone.prototype.isUTC = function () {
return this.timezone === 'Etc/UTC';
};
return Timezone;
}());
Timezone.UTC = new Timezone('Etc/UTC');
check = Timezone;
function adjustDay(day) {

@@ -390,3 +339,3 @@ return (day + 6) % 7;

}
var check$1;
var check;
var Duration = (function () {

@@ -464,2 +413,10 @@ function Duration(spans, end, timezone) {

};
Duration.prototype.multiply = function (multiplier) {
if (multiplier <= 0)
throw new Error("Multiplier must be positive non-zero");
if (multiplier === 1)
return this;
var newCanonicalDuration = this.getCanonicalLength() * multiplier;
return Duration.fromCanonicalLength(newCanonicalDuration);
};
Duration.prototype.valueOf = function () {

@@ -580,4 +537,55 @@ return this.spans;

}());
check$1 = Duration;
check = Duration;
var check$1;
var Timezone = (function () {
function Timezone(timezone) {
if (typeof timezone !== 'string') {
throw new TypeError("timezone description must be a string");
}
if (timezone !== 'Etc/UTC' && !moment.tz.zone(timezone)) {
throw new Error("timezone '" + timezone + "' does not exist");
}
this.timezone = timezone;
}
Timezone.isTimezone = function (candidate) {
return candidate instanceof Timezone;
};
Timezone.formatDateWithTimezone = function (d, timezone) {
var str;
if (timezone && !timezone.isUTC()) {
str = moment.tz(d, timezone.toString()).format('YYYY-MM-DDTHH:mm:ss.SSSZ');
}
else {
str = d.toISOString();
}
return str.replace('.000', '');
};
Timezone.fromJS = function (spec) {
return new Timezone(spec);
};
Timezone.prototype.valueOf = function () {
return this.timezone;
};
Timezone.prototype.toJS = function () {
return this.timezone;
};
Timezone.prototype.toJSON = function () {
return this.timezone;
};
Timezone.prototype.toString = function () {
return this.timezone;
};
Timezone.prototype.equals = function (other) {
return Timezone.isTimezone(other) &&
this.timezone === other.timezone;
};
Timezone.prototype.isUTC = function () {
return this.timezone === 'Etc/UTC';
};
return Timezone;
}());
Timezone.UTC = new Timezone('Etc/UTC');
check$1 = Timezone;
function parseYear(v) {

@@ -584,0 +592,0 @@ if (v.length === 2) {

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

import { Duration } from '../duration/duration';
import { Timezone } from '../timezone/timezone';
import { Duration } from '../duration/duration';
export declare function parseSQLDate(type: string, v: string): Date;

@@ -4,0 +4,0 @@ export declare function parseISODate(date: string, timezone?: Timezone): Date | null;

import * as moment from 'moment-timezone';
import { Duration } from '../duration/duration';
import { Timezone } from '../timezone/timezone';
import { Duration } from '../duration/duration';
function parseYear(v) {

@@ -5,0 +5,0 @@ if (v.length === 2) {

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

import { expect, assert } from "chai";
import { assert, expect } from 'chai';
import { Timezone } from '../timezone/timezone';
import { parseInterval, parseISODate } from './date-parser';
var deepEqual = assert.deepEqual;
import { Timezone } from '../timezone/timezone';
import { parseISODate, parseInterval } from './date-parser';
describe('date parser', function () {

@@ -6,0 +6,0 @@ describe('parseISODate', function () {

@@ -24,2 +24,3 @@ import { Instance } from 'immutable-class';

subtract(duration: Duration): Duration;
multiply(multiplier: number): Duration;
valueOf(): DurationValue;

@@ -26,0 +27,0 @@ toJS(): string;

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

import { shifters, second } from '../floor-shift-ceil/floor-shift-ceil';
import { second, shifters } from '../floor-shift-ceil/floor-shift-ceil';
var spansWithWeek = ["year", "month", "week", "day", "hour", "minute", "second"];

@@ -155,2 +155,10 @@ var spansWithoutWeek = ["year", "month", "day", "hour", "minute", "second"];

};
Duration.prototype.multiply = function (multiplier) {
if (multiplier <= 0)
throw new Error("Multiplier must be positive non-zero");
if (multiplier === 1)
return this;
var newCanonicalDuration = this.getCanonicalLength() * multiplier;
return Duration.fromCanonicalLength(newCanonicalDuration);
};
Duration.prototype.valueOf = function () {

@@ -157,0 +165,0 @@ return this.spans;

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

import { expect } from "chai";
import { expect } from 'chai';
import { testImmutableClass } from 'immutable-class-tester';
import { Duration } from '../duration/duration';
import { Timezone } from '../timezone/timezone';
import { Duration } from '../duration/duration';
describe("Duration", function () {

@@ -229,2 +229,24 @@ var TZ_LA = Timezone.fromJS("America/Los_Angeles");

});
describe("#multiply()", function () {
it("works with a simple duration", function () {
var d = Duration.fromJS("P1D");
expect(d.multiply(5).toJS()).to.eql("P5D");
});
it("works with a less simple duration", function () {
var d = Duration.fromJS("P1DT2H");
expect(d.multiply(2).toJS()).to.eql("P2DT4H");
});
it("works with weeks", function () {
var d = Duration.fromJS("P1W");
expect(d.multiply(5).toJS()).to.eql("P1M5D");
});
it("throws an error if result is going to be negative", function () {
var d = Duration.fromJS("P1D");
expect(function () { return d.multiply(-1); }).to.throw('Multiplier must be positive non-zero');
});
it("gets description properly", function () {
var d = Duration.fromJS("P2D");
expect(d.multiply(2).getDescription(true)).to.equal("4 Days");
});
});
describe("#getDescription()", function () {

@@ -231,0 +253,0 @@ it("gives back the correct description", function () {

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

import { expect } from "chai";
import { expect } from 'chai';
import { Timezone } from '../timezone/timezone';

@@ -3,0 +3,0 @@ import { shifters } from './floor-shift-ceil';

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

import { expect } from "chai";
import { expect } from 'chai';
import { Timezone } from '../timezone/timezone';

@@ -3,0 +3,0 @@ import { shifters } from './floor-shift-ceil';

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

import { expect } from "chai";
import { expect } from 'chai';
import { testImmutableClass } from 'immutable-class-tester';

@@ -3,0 +3,0 @@ import { Timezone } from './timezone';

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

import { expect } from "chai";
import { expect } from 'chai';
import { isDate } from './utils';

@@ -3,0 +3,0 @@ describe("util", function () {

{
"name": "chronoshift",
"version": "0.6.6",
"version": "0.6.7",
"description": "A tiny library for shifting time with timezones",

@@ -30,3 +30,3 @@ "keywords": [

"scripts": {
"prepublish": "node_modules/.bin/tdi",
"prepare": "tdi",
"test": "./travis-test",

@@ -41,25 +41,25 @@ "compile": "./compile"

"dependencies": {
"immutable-class": "~0.6.20",
"moment-timezone": "~0.5.10",
"tslib": "^1.2.0"
"immutable-class": "~0.6.28",
"moment-timezone": "~0.5.13",
"tslib": "^1.7.0"
},
"devDependencies": {
"@types/mocha": "2.2.33",
"babel-core": "6.18.2",
"babel-preset-es2015": "6.18.0",
"@types/mocha": "2.2.41",
"babel-core": "6.24.1",
"babel-preset-es2015": "6.24.1",
"blanket": "1.2.3",
"browserify": "13.1.1",
"browserify": "14.3.0",
"chai": "3.5.0",
"event-stream": "3.3.4",
"gulp": "3.9.1",
"gulp-mocha": "3.0.1",
"gulp-typescript": "3.1.3",
"immutable-class-tester": "0.5.8",
"mocha": "3.2.0",
"rollup": "0.36.4",
"gulp-mocha": "4.3.1",
"gulp-typescript": "3.1.6",
"immutable-class-tester": "0.5.10",
"mocha": "3.3.0",
"rollup": "0.41.6",
"run-sequence": "1.2.2",
"tdi": "0.2.3",
"tslint": "4.0.2",
"typescript": "2.1.4"
"tdi": "0.2.26",
"tslint": "5.2.0",
"typescript": "2.2.2"
}
}
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