Socket
Socket
Sign inDemoInstall

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.24.1 to 1.25.0

11

CHANGELOG.md
# Changelog
## 1.25.0
* fix fromFormat with Intl formats containing non-breaking spaces
* Support higher precisision in ISO milliseconds
* Some fixes for 00:30 timezones
* Fix some throwOnInvalid for invalid Intervals
* Various doc fixes
* Fix Interval#isSame for empty intervals
* Mark package as side effect-free
* Add support for intervals with a large number of seconds
## 1.24.1 (2020-05-04)

@@ -4,0 +15,0 @@

5

package.json
{
"name": "luxon",
"version": "1.24.1",
"version": "1.25.0",
"description": "Immutable date wrapper",

@@ -94,3 +94,4 @@ "author": "Isaac Cambron",

],
"license": "MIT"
"license": "MIT",
"sideEffects": false
}

@@ -40,2 +40,3 @@ import { InvalidArgumentError, InvalidDurationError, InvalidUnitError } from "./errors.js";

years: {
quarters: 4,
months: 12,

@@ -55,2 +56,3 @@ weeks: 52,

minutes: 91 * 24 * 60,
seconds: 91 * 24 * 60 * 60,
milliseconds: 91 * 24 * 60 * 60 * 1000

@@ -74,2 +76,3 @@ },

years: {
quarters: 4,
months: 12,

@@ -594,4 +597,2 @@ weeks: daysInYearAccurate / 7,

normalizeValues(this.matrix, vals);
for (const k of orderedUnits) {

@@ -598,0 +599,0 @@ if (units.indexOf(k) >= 0) {

2

src/impl/english.js

@@ -190,2 +190,4 @@ import * as Formats from "./formats.js";

return "LLL d, yyyy";
case stringify(Formats.DATE_MED_WITH_WEEKDAY):
return "EEE, LLL d, yyyy";
case stringify(Formats.DATE_FULL):

@@ -192,0 +194,0 @@ return "LLLL d, yyyy";

@@ -21,2 +21,9 @@ /**

export const DATE_MED_WITH_WEEKDAY = {
year: n,
month: s,
day: n,
weekday: s
};
export const DATE_FULL = {

@@ -23,0 +30,0 @@ year: n,

@@ -69,3 +69,3 @@ import {

const offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/,
isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,9}))?)?)?/,
isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,
isoTimeRegex = RegExp(`${isoTimeBaseRegex.source}${offsetRegex.source}?`),

@@ -124,3 +124,3 @@ isoTimeExtensionRegex = RegExp(`(?:T${isoTimeRegex.source})?`),

const isoDuration = /^-?P(?:(?:(-?\d{1,9})Y)?(?:(-?\d{1,9})M)?(?:(-?\d{1,9})W)?(?:(-?\d{1,9})D)?(?:T(?:(-?\d{1,9})H)?(?:(-?\d{1,9})M)?(?:(-?\d{1,9})(?:[.,](-?\d{1,9}))?S)?)?)$/;
const isoDuration = /^-?P(?:(?:(-?\d{1,9})Y)?(?:(-?\d{1,9})M)?(?:(-?\d{1,9})W)?(?:(-?\d{1,9})D)?(?:T(?:(-?\d{1,9})H)?(?:(-?\d{1,9})M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,9}))?S)?)?)$/;

@@ -127,0 +127,0 @@ function extractISODuration(match) {

@@ -15,9 +15,17 @@ import { parseMillis, isUndefined, untruncateYear, signedOffset, hasOwnProperty } from "./util.js";

const NBSP = String.fromCharCode(160);
const spaceOrNBSP = `( |${NBSP})`;
const spaceOrNBSPRegExp = new RegExp(spaceOrNBSP, "g");
function fixListRegex(s) {
// make dots optional and also make them literal
return s.replace(/\./, "\\.?");
// make space and non breakable space characters interchangeable
return s.replace(/\./g, "\\.?").replace(spaceOrNBSPRegExp, spaceOrNBSP);
}
function stripInsensitivities(s) {
return s.replace(/\./, "").toLowerCase();
return s
.replace(/\./g, "") // ignore dots that were made optional
.replace(spaceOrNBSPRegExp, " ") // interchange space and nbsp
.toLowerCase();
}

@@ -24,0 +32,0 @@

@@ -266,14 +266,13 @@ /*

export function formatOffset(offset, format) {
const hours = Math.trunc(offset / 60),
minutes = Math.abs(offset % 60),
sign = hours >= 0 && !Object.is(hours, -0) ? "+" : "-",
base = `${sign}${Math.abs(hours)}`;
const hours = Math.trunc(Math.abs(offset / 60)),
minutes = Math.trunc(Math.abs(offset % 60)),
sign = offset >= 0 ? "+" : "-";
switch (format) {
case "short":
return `${sign}${padStart(Math.abs(hours), 2)}:${padStart(minutes, 2)}`;
return `${sign}${padStart(hours, 2)}:${padStart(minutes, 2)}`;
case "narrow":
return minutes > 0 ? `${base}:${minutes}` : base;
return `${sign}${hours}${minutes > 0 ? `:${minutes}` : ""}`;
case "techie":
return `${sign}${padStart(Math.abs(hours), 2)}${padStart(minutes, 2)}`;
return `${sign}${padStart(hours, 2)}${padStart(minutes, 2)}`;
default:

@@ -280,0 +279,0 @@ throw new RangeError(`Value format ${format} is out of range for property format`);

@@ -98,3 +98,3 @@ import DateTime from "./datetime.js";

* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
* @param {string} [length='long'] - the length of the month representation, such as "narrow", "short", "long".
* @param {string} [length='long'] - the length of the weekday representation, such as "narrow", "short", "long".
* @param {Object} opts - options

@@ -118,3 +118,3 @@ * @param {string} [opts.locale] - the locale code

* See {@link weekdays}
* @param {string} [length='long'] - the length of the month representation, such as "narrow", "short", "long".
* @param {string} [length='long'] - the length of the weekday representation, such as "narrow", "short", "long".
* @param {Object} opts - options

@@ -121,0 +121,0 @@ * @param {string} [opts.locale=null] - the locale code

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

* * **Transformation** To create other Intervals out of this one, use {@link set}, {@link splitAt}, {@link splitBy}, {@link divideEqually}, {@link merge}, {@link xor}, {@link union}, {@link intersection}, or {@link difference}.
* * **Comparison** To compare this Interval to another one, use {@link equals}, {@link overlaps}, {@link abutsStart}, {@link abutsEnd}, {@link engulfs}
* * **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 toISODate}, {@link toISOTime}, {@link toFormat}, and {@link toDuration}.

@@ -138,10 +138,23 @@ */

if (s && e) {
const start = DateTime.fromISO(s, opts),
let start, startIsValid;
try {
start = DateTime.fromISO(s, opts);
startIsValid = start.isValid;
} catch (e) {
startIsValid = false;
}
let end, endIsValid;
try {
end = DateTime.fromISO(e, opts);
endIsValid = end.isValid;
} catch (e) {
endIsValid = false;
}
if (start.isValid && end.isValid) {
if (startIsValid && endIsValid) {
return Interval.fromDateTimes(start, end);
}
if (start.isValid) {
if (startIsValid) {
const dur = Duration.fromISO(e, opts);

@@ -151,3 +164,3 @@ if (dur.isValid) {

}
} else if (end.isValid) {
} else if (endIsValid) {
const dur = Duration.fromISO(s, opts);

@@ -240,3 +253,3 @@ if (dur.isValid) {

hasSame(unit) {
return this.isValid ? this.e.minus(1).hasSame(this.s, unit) : false;
return this.isValid ? this.isEmpty() || this.e.minus(1).hasSame(this.s, unit) : false;
}

@@ -243,0 +256,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