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

luxon

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

luxon - npm Package Compare versions

Comparing version 1.19.3 to 1.20.0

12

changelog.md
# Changelog
# 1.19.3
## 1.20.0
* Added Duration#mapUnits
* added Interval#toISODate and Interval#toISOTime
* Some documentation fixes
## 1.19.3
* Cache offset values
* Fix handling of negative sub 1-hour offsets
# 1.19.2
## 1.19.2
* Speculative fix for Node 6
# 1.19.1
## 1.19.1

@@ -14,0 +20,0 @@ * Fix Intl.DateTimeFormat usage for polyfills

{
"name": "luxon",
"version": "1.19.3",
"version": "1.20.0",
"description": "Immutable date wrapper",

@@ -5,0 +5,0 @@ "author": "Isaac Cambron",

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

import { isUndefined, isNumber, normalizeObject, hasOwnProperty } from "./impl/util.js";
import { isUndefined, isNumber, normalizeObject, hasOwnProperty, asNumber } from "./impl/util.js";
import Locale from "./impl/locale.js";

@@ -481,2 +481,18 @@ import Formatter from "./impl/formatter.js";

/**
* Scale this Duration by the specified amount. Return a newly-constructed Duration.
* @param {function} fn - The function to apply to each unit. Arity is 1 or 2: the value of the unit and, optionally, the unit name. Must return a number.
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit(x => x * 2) //=> { hours: 2, minutes: 60 }
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
* @return {Duration}
*/
mapUnits(fn) {
if (!this.isValid) return this;
const result = {};
for (const k of Object.keys(this.values)) {
result[k] = asNumber(fn(this.values[k], k));
}
return clone(this, { values: result }, true);
}
/**
* Get the value of unit.

@@ -483,0 +499,0 @@ * @param {string} unit - a unit such as 'minute' or 'day'

@@ -7,4 +7,3 @@ /**

s = "short",
l = "long",
d2 = "2-digit";
l = "long";

@@ -38,3 +37,3 @@ export const DATE_SHORT = {

hour: n,
minute: d2
minute: n
};

@@ -44,4 +43,4 @@

hour: n,
minute: d2,
second: d2
minute: n,
second: n
};

@@ -51,4 +50,4 @@

hour: n,
minute: d2,
second: d2,
minute: n,
second: n,
timeZoneName: s

@@ -59,4 +58,4 @@ };

hour: n,
minute: d2,
second: d2,
minute: n,
second: n,
timeZoneName: l

@@ -67,3 +66,3 @@ };

hour: n,
minute: d2,
minute: n,
hour12: false

@@ -77,4 +76,4 @@ };

hour: n,
minute: d2,
second: d2,
minute: n,
second: n,
hour12: false

@@ -88,4 +87,4 @@ };

hour: n,
minute: d2,
second: d2,
minute: n,
second: n,
hour12: false,

@@ -100,4 +99,4 @@ timeZoneName: s

hour: n,
minute: d2,
second: d2,
minute: n,
second: n,
hour12: false,

@@ -115,3 +114,3 @@ timeZoneName: l

hour: n,
minute: d2
minute: n
};

@@ -127,4 +126,4 @@

hour: n,
minute: d2,
second: d2
minute: n,
second: n
};

@@ -137,3 +136,3 @@

hour: n,
minute: d2
minute: n
};

@@ -146,4 +145,4 @@

hour: n,
minute: d2,
second: d2
minute: n,
second: n
};

@@ -157,3 +156,3 @@

hour: n,
minute: d2
minute: n
};

@@ -166,3 +165,3 @@

hour: n,
minute: d2,
minute: n,
timeZoneName: s

@@ -176,4 +175,4 @@ };

hour: n,
minute: d2,
second: d2,
minute: n,
second: n,
timeZoneName: s

@@ -188,3 +187,3 @@ };

hour: n,
minute: d2,
minute: n,
timeZoneName: l

@@ -199,5 +198,5 @@ };

hour: n,
minute: d2,
second: d2,
minute: n,
second: n,
timeZoneName: l
};

@@ -19,3 +19,3 @@ import { hasFormatToParts, hasIntl, padStart, roundTo, hasRelative } from "./util.js";

let intlNumCache = {};
function getCachendINF(locString, opts = {}) {
function getCachedINF(locString, opts = {}) {
const key = JSON.stringify([locString, opts]);

@@ -31,3 +31,3 @@ let inf = intlNumCache[key];

let intlRelCache = {};
function getCachendRTF(locString, opts = {}) {
function getCachedRTF(locString, opts = {}) {
const key = JSON.stringify([locString, opts]);

@@ -160,3 +160,3 @@ let inf = intlRelCache[key];

if (opts.padTo > 0) intlOpts.minimumIntegerDigits = opts.padTo;
this.inf = getCachendINF(intl, intlOpts);
this.inf = getCachedINF(intl, intlOpts);
}

@@ -259,3 +259,3 @@ }

if (!isEnglish && hasRelative()) {
this.rtf = getCachendRTF(intl, opts);
this.rtf = getCachedRTF(intl, opts);
}

@@ -262,0 +262,0 @@ }

@@ -245,3 +245,3 @@ /*

function asNumber(value) {
export function asNumber(value) {
const numericValue = Number(value);

@@ -248,0 +248,0 @@ if (typeof value === "boolean" || value === "" || Number.isNaN(numericValue))

@@ -35,3 +35,3 @@ import DateTime, { friendlyDateTime } from "./datetime.js";

* * **Comparison** To compare this Interval to another one, use {@link equals}, {@link overlaps}, {@link abutsStart}, {@link abutsEnd}, {@link engulfs}
* * **Output*** To convert the Interval into other representations, see {@link toString}, {@link toISO}, {@link toFormat}, and {@link toDuration}.
* * **Output** To convert the Interval into other representations, see {@link toString}, {@link toISO}, {@link toISODate}, {@link toISOTime}, {@link toFormat}, and {@link toDuration}.
*/

@@ -186,3 +186,3 @@ export default class Interval {

/**
* Returns whether this Interval's end is at least its start, i.e. that the Interval isn't 'backwards'.
* Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'.
* @type {boolean}

@@ -411,3 +411,3 @@ */

* Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals.
* Returns null if the intersection is empty, i.e., the intervals don't intersect.
* Returns null if the intersection is empty, meaning, the intervals don't intersect.
* @param {Interval} other

@@ -528,2 +528,25 @@ * @return {Interval}

/**
* Returns an ISO 8601-compliant string representation of date of this Interval.
* The time components are ignored.
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
* @return {string}
*/
toISODate() {
if (!this.isValid) return INVALID;
return `${this.s.toISODate()}/${this.e.toISODate()}`;
}
/**
* Returns an ISO 8601-compliant string representation of time of this Interval.
* The date components are ignored.
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
* @param {Object} opts - The same options as {@link DateTime.toISO}
* @return {string}
*/
toISOTime(opts) {
if (!this.isValid) return INVALID;
return `${this.s.toISOTime(opts)}/${this.e.toISOTime(opts)}`;
}
/**
* Returns a string representation of this Interval formatted according to the specified format string.

@@ -530,0 +553,0 @@ * @param {string} dateFormat - the format string. This string formats the start and end time. See {@link DateTime.toFormat} for details.

@@ -7,3 +7,3 @@ import { formatOffset, signedOffset } from "../impl/util.js";

/**
* A zone with a fixed offset (i.e. no DST)
* A zone with a fixed offset (meaning no DST)
* @implements {Zone}

@@ -10,0 +10,0 @@ */

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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