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

chronoshift

Package Overview
Dependencies
Maintainers
2
Versions
49
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.5 to 0.6.6

22

build/chronoshift.js

@@ -21,2 +21,12 @@ 'use strict';

};
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) {

@@ -44,5 +54,5 @@ return new Timezone(spec);

};
Timezone.UTC = new Timezone('Etc/UTC');
return Timezone;
}());
Timezone.UTC = new Timezone('Etc/UTC');
check = Timezone;

@@ -342,8 +352,8 @@

var spanCount = 0;
var length = end.valueOf() - iterator.valueOf();
var length_1 = end.valueOf() - iterator.valueOf();
var canonicalLength = shifters[span].canonicalLength;
if (length < canonicalLength / 4)
if (length_1 < canonicalLength / 4)
continue;
var numberToFit = Math.min(0, Math.floor(length / canonicalLength) - 1);
var iteratorMove;
var numberToFit = Math.min(0, Math.floor(length_1 / canonicalLength) - 1);
var iteratorMove = void 0;
if (numberToFit > 0) {

@@ -654,3 +664,3 @@ iteratorMove = shifters[span].shift(iterator, timezone, numberToFit);

if ((struct = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2})(?::?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?)?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?$/.exec(date))) {
for (var i = 0, k; (k = numericKeys[i]); ++i) {
for (var i = 0, k = void 0; (k = numericKeys[i]); ++i) {
struct[k] = +struct[k] || 0;

@@ -657,0 +667,0 @@ }

@@ -86,3 +86,3 @@ import * as moment from 'moment-timezone';

if ((struct = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2})(?::?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?)?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?$/.exec(date))) {
for (var i = 0, k; (k = numericKeys[i]); ++i) {
for (var i = 0, k = void 0; (k = numericKeys[i]); ++i) {
struct[k] = +struct[k] || 0;

@@ -89,0 +89,0 @@ }

@@ -7,3 +7,4 @@ import { expect, assert } from "chai";

describe('parseISODate', function () {
var sixHours = 6 * 60 * 60 * 1000, sixHoursThirty = sixHours + 30 * 60 * 1000;
var sixHours = 6 * 60 * 60 * 1000;
var sixHoursThirty = sixHours + 30 * 60 * 1000;
it('date-part', function () {

@@ -10,0 +11,0 @@ deepEqual(parseISODate('1970-01-01'), new Date(Date.UTC(1970, 0, 1, 0, 0, 0, 0)), 'Unix epoch');

@@ -43,8 +43,8 @@ import { shifters, second } from '../floor-shift-ceil/floor-shift-ceil';

var spanCount = 0;
var length = end.valueOf() - iterator.valueOf();
var length_1 = end.valueOf() - iterator.valueOf();
var canonicalLength = shifters[span].canonicalLength;
if (length < canonicalLength / 4)
if (length_1 < canonicalLength / 4)
continue;
var numberToFit = Math.min(0, Math.floor(length / canonicalLength) - 1);
var iteratorMove;
var numberToFit = Math.min(0, Math.floor(length_1 / canonicalLength) - 1);
var iteratorMove = void 0;
if (numberToFit > 0) {

@@ -84,3 +84,3 @@ iteratorMove = shifters[span].shift(iterator, timezone, numberToFit);

var check;
export var Duration = (function () {
var Duration = (function () {
function Duration(spans, end, timezone) {

@@ -272,2 +272,3 @@ if (spans && end && timezone) {

}());
export { Duration };
check = Duration;

@@ -27,3 +27,3 @@ import { expect } from "chai";

it("throws error if fromJS is not given a string", function () {
expect(function () { return Duration.fromJS((new Date())); }).to.throw(Error, "Duration JS must be a string");
expect(function () { return Duration.fromJS(new Date()); }).to.throw(Error, "Duration JS must be a string");
});

@@ -30,0 +30,0 @@ });

@@ -6,2 +6,2 @@ export * from './date-parser/date-parser';

export * from './utils/utils';
export declare var moment: any;
export declare let moment: any;

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

static isTimezone(candidate: any): boolean;
static formatDateWithTimezone(d: Date, timezone?: Timezone): string;
static fromJS(spec: string): Timezone;

@@ -8,0 +9,0 @@ constructor(timezone: string);

import * as moment from 'moment-timezone';
var check;
export var Timezone = (function () {
var Timezone = (function () {
function Timezone(timezone) {

@@ -16,2 +16,12 @@ if (typeof timezone !== 'string') {

};
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) {

@@ -39,5 +49,6 @@ return new Timezone(spec);

};
Timezone.UTC = new Timezone('Etc/UTC');
return Timezone;
}());
export { Timezone };
Timezone.UTC = new Timezone('Etc/UTC');
check = Timezone;
import { expect } from "chai";
import { testImmutableClass } from 'immutable-class-tester';
import { Timezone } from '../timezone/timezone';
import { Timezone } from './timezone';
describe("Timezone", function () {

@@ -32,3 +32,3 @@ it("is an immutable class", function () {

});
describe("isTimezone", function () {
describe(".isTimezone", function () {
it("gives back the correct string for LA", function () {

@@ -39,2 +39,18 @@ var timezoneStr = "America/Los_Angeles";

});
describe(".formatDateWithTimezone", function () {
it("works with no timezone", function () {
expect(Timezone.formatDateWithTimezone(new Date("2016-12-08T19:46:13.915Z"))).to.equal("2016-12-08T19:46:13.915Z");
expect(Timezone.formatDateWithTimezone(new Date("2016-12-08T19:46:13.000Z"))).to.equal("2016-12-08T19:46:13Z");
});
it("works with UTC", function () {
var tz = Timezone.UTC;
expect(Timezone.formatDateWithTimezone(new Date("2016-12-08T19:46:13.915Z"), tz)).to.equal("2016-12-08T19:46:13.915Z");
expect(Timezone.formatDateWithTimezone(new Date("2016-12-08T19:46:13.000Z"), tz)).to.equal("2016-12-08T19:46:13Z");
});
it("works with Asia/Kathmandu", function () {
var tz = Timezone.fromJS('Asia/Kathmandu');
expect(Timezone.formatDateWithTimezone(new Date("2016-12-08T19:46:13.915Z"), tz)).to.equal("2016-12-09T01:31:13.915+05:45");
expect(Timezone.formatDateWithTimezone(new Date("2016-12-08T19:46:13.000Z"), tz)).to.equal("2016-12-09T01:31:13+05:45");
});
});
});
{
"name": "chronoshift",
"version": "0.6.5",
"version": "0.6.6",
"description": "A tiny library for shifting time with timezones",

@@ -41,6 +41,7 @@ "keywords": [

"immutable-class": "~0.6.20",
"moment-timezone": "~0.5.9"
"moment-timezone": "~0.5.10",
"tslib": "^1.2.0"
},
"devDependencies": {
"@types/mocha": "2.2.32",
"@types/mocha": "2.2.33",
"babel-core": "6.18.2",

@@ -54,11 +55,11 @@ "babel-preset-es2015": "6.18.0",

"gulp-mocha": "3.0.1",
"gulp-typescript": "3.1.2",
"gulp-typescript": "3.1.3",
"immutable-class-tester": "0.5.8",
"mocha": "3.1.2",
"rollup": "0.36.3",
"mocha": "3.2.0",
"rollup": "0.36.4",
"run-sequence": "1.2.2",
"tdi": "0.1.6",
"tslint": "3.15.1",
"typescript": "2.0.8"
"tdi": "0.2.3",
"tslint": "4.0.2",
"typescript": "2.1.4"
}
}
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