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.7.2 to 0.7.3

41

build/chronoshift.js

@@ -252,4 +252,5 @@ 'use strict';

var spansWithWeek = ["year", "month", "week", "day", "hour", "minute", "second"];
var spansWithoutWeek = ["year", "month", "day", "hour", "minute", "second"];
var SPANS_WITH_WEEK = ["year", "month", "week", "day", "hour", "minute", "second"];
var SPANS_WITHOUT_WEEK = ["year", "month", "day", "hour", "minute", "second"];
var SPANS_WITHOUT_WEEK_OR_MONTH = ["year", "day", "hour", "minute", "second"];
function capitalizeFirst(str) {

@@ -272,4 +273,4 @@ if (!str.length)

var nums = matches.map(Number);
for (var i = 0; i < spansWithoutWeek.length; i++) {
var span = spansWithoutWeek[i];
for (var i = 0; i < SPANS_WITHOUT_WEEK.length; i++) {
var span = SPANS_WITHOUT_WEEK[i];
var value = nums[i + 1];

@@ -292,4 +293,4 @@ if (value)

var iterator = start;
for (var i = 0; i < spansWithoutWeek.length; i++) {
var span = spansWithoutWeek[i];
for (var i = 0; i < SPANS_WITHOUT_WEEK.length; i++) {
var span = SPANS_WITHOUT_WEEK[i];
var spanCount = 0;

@@ -327,4 +328,4 @@ var length_1 = end.valueOf() - iterator.valueOf();

var newSpans = {};
for (var i = 0; i < spansWithWeek.length; i++) {
var span = spansWithWeek[i];
for (var i = 0; i < SPANS_WITH_WEEK.length; i++) {
var span = SPANS_WITH_WEEK[i];
if (spans[span] > 0) {

@@ -363,10 +364,12 @@ newSpans[span] = spans[span];

};
Duration.fromCanonicalLength = function (length) {
Duration.fromCanonicalLength = function (length, skipMonths) {
if (skipMonths === void 0) { skipMonths = false; }
if (length <= 0)
throw new Error('length must be positive');
var spansToCheck = skipMonths ? SPANS_WITHOUT_WEEK_OR_MONTH : SPANS_WITHOUT_WEEK;
var spans = {};
var spansUsed = 0;
var lengthLeft = length;
for (var i = 0; i < spansWithoutWeek.length; i++) {
var span = spansWithoutWeek[i];
for (var i = 0; i < spansToCheck.length; i++) {
var span = spansToCheck[i];
var spanLength = shifters[span].canonicalLength;

@@ -398,4 +401,4 @@ var count = Math.floor(lengthLeft / spanLength);

var addedT = false;
for (var i = 0; i < spansWithoutWeek.length; i++) {
var span = spansWithoutWeek[i];
for (var i = 0; i < SPANS_WITHOUT_WEEK.length; i++) {
var span = SPANS_WITHOUT_WEEK[i];
var value = spans[span];

@@ -480,4 +483,4 @@ if (!value)

var spans = this.spans;
for (var _i = 0, spansWithWeek_1 = spansWithWeek; _i < spansWithWeek_1.length; _i++) {
var span = spansWithWeek_1[_i];
for (var _i = 0, SPANS_WITH_WEEK_1 = SPANS_WITH_WEEK; _i < SPANS_WITH_WEEK_1.length; _i++) {
var span = SPANS_WITH_WEEK_1[_i];
var value = spans[span];

@@ -510,4 +513,4 @@ if (value)

var length = 0;
for (var _i = 0, spansWithWeek_2 = spansWithWeek; _i < spansWithWeek_2.length; _i++) {
var span = spansWithWeek_2[_i];
for (var _i = 0, SPANS_WITH_WEEK_2 = SPANS_WITH_WEEK; _i < SPANS_WITH_WEEK_2.length; _i++) {
var span = SPANS_WITH_WEEK_2[_i];
var value = spans[span];

@@ -522,4 +525,4 @@ if (value)

var description = [];
for (var _i = 0, spansWithWeek_3 = spansWithWeek; _i < spansWithWeek_3.length; _i++) {
var span = spansWithWeek_3[_i];
for (var _i = 0, SPANS_WITH_WEEK_3 = SPANS_WITH_WEEK; _i < SPANS_WITH_WEEK_3.length; _i++) {
var span = SPANS_WITH_WEEK_3[_i];
var value = spans[span];

@@ -526,0 +529,0 @@ var spanTitle = capitalize ? capitalizeFirst(span) : span;

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

static fromJS(durationStr: string): Duration;
static fromCanonicalLength(length: number): Duration;
static fromCanonicalLength(length: number, skipMonths?: boolean): Duration;
static isDuration(candidate: any): boolean;

@@ -20,0 +20,0 @@ constructor(spans: DurationValue);

import { second, shifters } from '../floor-shift-ceil/floor-shift-ceil';
var spansWithWeek = ["year", "month", "week", "day", "hour", "minute", "second"];
var spansWithoutWeek = ["year", "month", "day", "hour", "minute", "second"];
var SPANS_WITH_WEEK = ["year", "month", "week", "day", "hour", "minute", "second"];
var SPANS_WITHOUT_WEEK = ["year", "month", "day", "hour", "minute", "second"];
var SPANS_WITHOUT_WEEK_OR_MONTH = ["year", "day", "hour", "minute", "second"];
function capitalizeFirst(str) {

@@ -21,4 +22,4 @@ if (!str.length)

var nums = matches.map(Number);
for (var i = 0; i < spansWithoutWeek.length; i++) {
var span = spansWithoutWeek[i];
for (var i = 0; i < SPANS_WITHOUT_WEEK.length; i++) {
var span = SPANS_WITHOUT_WEEK[i];
var value = nums[i + 1];

@@ -41,4 +42,4 @@ if (value)

var iterator = start;
for (var i = 0; i < spansWithoutWeek.length; i++) {
var span = spansWithoutWeek[i];
for (var i = 0; i < SPANS_WITHOUT_WEEK.length; i++) {
var span = SPANS_WITHOUT_WEEK[i];
var spanCount = 0;

@@ -76,4 +77,4 @@ var length_1 = end.valueOf() - iterator.valueOf();

var newSpans = {};
for (var i = 0; i < spansWithWeek.length; i++) {
var span = spansWithWeek[i];
for (var i = 0; i < SPANS_WITH_WEEK.length; i++) {
var span = SPANS_WITH_WEEK[i];
if (spans[span] > 0) {

@@ -113,10 +114,12 @@ newSpans[span] = spans[span];

};
Duration.fromCanonicalLength = function (length) {
Duration.fromCanonicalLength = function (length, skipMonths) {
if (skipMonths === void 0) { skipMonths = false; }
if (length <= 0)
throw new Error('length must be positive');
var spansToCheck = skipMonths ? SPANS_WITHOUT_WEEK_OR_MONTH : SPANS_WITHOUT_WEEK;
var spans = {};
var spansUsed = 0;
var lengthLeft = length;
for (var i = 0; i < spansWithoutWeek.length; i++) {
var span = spansWithoutWeek[i];
for (var i = 0; i < spansToCheck.length; i++) {
var span = spansToCheck[i];
var spanLength = shifters[span].canonicalLength;

@@ -148,4 +151,4 @@ var count = Math.floor(lengthLeft / spanLength);

var addedT = false;
for (var i = 0; i < spansWithoutWeek.length; i++) {
var span = spansWithoutWeek[i];
for (var i = 0; i < SPANS_WITHOUT_WEEK.length; i++) {
var span = SPANS_WITHOUT_WEEK[i];
var value = spans[span];

@@ -230,4 +233,4 @@ if (!value)

var spans = this.spans;
for (var _i = 0, spansWithWeek_1 = spansWithWeek; _i < spansWithWeek_1.length; _i++) {
var span = spansWithWeek_1[_i];
for (var _i = 0, SPANS_WITH_WEEK_1 = SPANS_WITH_WEEK; _i < SPANS_WITH_WEEK_1.length; _i++) {
var span = SPANS_WITH_WEEK_1[_i];
var value = spans[span];

@@ -260,4 +263,4 @@ if (value)

var length = 0;
for (var _i = 0, spansWithWeek_2 = spansWithWeek; _i < spansWithWeek_2.length; _i++) {
var span = spansWithWeek_2[_i];
for (var _i = 0, SPANS_WITH_WEEK_2 = SPANS_WITH_WEEK; _i < SPANS_WITH_WEEK_2.length; _i++) {
var span = SPANS_WITH_WEEK_2[_i];
var value = spans[span];

@@ -272,4 +275,4 @@ if (value)

var description = [];
for (var _i = 0, spansWithWeek_3 = spansWithWeek; _i < spansWithWeek_3.length; _i++) {
var span = spansWithWeek_3[_i];
for (var _i = 0, SPANS_WITH_WEEK_3 = SPANS_WITH_WEEK; _i < SPANS_WITH_WEEK_3.length; _i++) {
var span = SPANS_WITH_WEEK_3[_i];
var value = spans[span];

@@ -276,0 +279,0 @@ var spanTitle = capitalize ? capitalizeFirst(span) : span;

@@ -63,2 +63,10 @@ import { expect } from 'chai';

});
it("works with months", function () {
expect(Duration.fromCanonicalLength(2592000000).toJS()).to.eql("P1M");
expect(Duration.fromCanonicalLength(2678400000).toJS()).to.eql("P1M1D");
});
it("works without months", function () {
expect(Duration.fromCanonicalLength(2592000000, true).toJS()).to.eql("P30D");
expect(Duration.fromCanonicalLength(2678400000, true).toJS()).to.eql("P31D");
});
});

@@ -65,0 +73,0 @@ describe("construct from span", function () {

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

@@ -5,0 +5,0 @@ "keywords": [

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