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.26.0 to 1.27.0

12

CHANGELOG.md
# Changelog
## 1.26.0
# 1.27.0 (2021-05-08)
* Fix GMT zone parsing for older versions of Node
* Support multiple units in `toRelative`
* Various documentation updates
## 1.26.0 (2021-02-13)
* Add fromISOTime, toISOTime and toMillis to Duration (#803)

@@ -11,6 +17,6 @@ * Fix padding of negative years in IsoDate (#871)

## 1.25.0
## 1.25.0 (2020-08-23)
* fix fromFormat with Intl formats containing non-breaking spaces
* Support higher precisision in ISO milliseconds
* Support higher precision in ISO milliseconds
* Some fixes for 00:30 timezones

@@ -17,0 +23,0 @@ * Fix some throwOnInvalid for invalid Intervals

{
"name": "luxon",
"version": "1.26.0",
"version": "1.27.0",
"description": "Immutable date wrapper",

@@ -22,3 +22,3 @@ "author": "Isaac Cambron",

"format": "prettier --write 'src/**/*.js' 'test/**/*.js' 'benchmarks/*.js'",
"benchmark": "babel-node benchmarks/datetime.js",
"benchmark": "babel-node benchmarks/index.js",
"codecov": "codecov",

@@ -25,0 +25,0 @@ "check-doc-coverage": "babel-node tasks/docCoverage"

@@ -596,5 +596,5 @@ import { InvalidArgumentError, InvalidDurationError, InvalidUnitError } from "./errors.js";

* @param {string} unit - a unit such as 'minute' or 'day'
* @example Duration.fromObject({years: 2, days: 3}).years //=> 2
* @example Duration.fromObject({years: 2, days: 3}).months //=> 0
* @example Duration.fromObject({years: 2, days: 3}).days //=> 3
* @example Duration.fromObject({years: 2, days: 3}).get('years') //=> 2
* @example Duration.fromObject({years: 2, days: 3}).get('months') //=> 0
* @example Duration.fromObject({years: 2, days: 3}).get('days') //=> 3
* @return {number}

@@ -601,0 +601,0 @@ */

@@ -47,7 +47,7 @@ import * as Formats from "./formats.js";

case "narrow":
return monthsNarrow;
return [...monthsNarrow];
case "short":
return monthsShort;
return [...monthsShort];
case "long":
return monthsLong;
return [...monthsLong];
case "numeric":

@@ -79,7 +79,7 @@ return ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

case "narrow":
return weekdaysNarrow;
return [...weekdaysNarrow];
case "short":
return weekdaysShort;
return [...weekdaysShort];
case "long":
return weekdaysLong;
return [...weekdaysLong];
case "numeric":

@@ -103,7 +103,7 @@ return ["1", "2", "3", "4", "5", "6", "7"];

case "narrow":
return erasNarrow;
return [...erasNarrow];
case "short":
return erasShort;
return [...erasShort];
case "long":
return erasLong;
return [...erasLong];
default:

@@ -110,0 +110,0 @@ return null;

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

import Formatter from "./formatter.js";
import IANAZone from "../zones/IANAZone.js";

@@ -189,7 +190,11 @@ let intlDTCache = {};

// That is why fixed-offset TZ is set to that unless it is:
// 1. Outside of the supported range Etc/GMT-14 to Etc/GMT+12.
// 2. Not a whole hour, e.g. UTC+4:30.
// 1. Representing offset 0 when UTC is used to maintain previous behavior and does not become GMT.
// 2. Unsupported by the browser:
// - some do not support Etc/
// - < Etc/GMT-14, > Etc/GMT+12, and 30-minute or 45-minute offsets are not part of tzdata
const gmtOffset = -1 * (dt.offset / 60);
if (gmtOffset >= -14 && gmtOffset <= 12 && gmtOffset % 1 === 0) {
z = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
const isOffsetZoneSupported = IANAZone.isValidZone(offsetZ);
if (dt.offset !== 0 && isOffsetZoneSupported) {
z = offsetZ;
this.dt = dt;

@@ -196,0 +201,0 @@ } else {

@@ -143,4 +143,6 @@ import {

const hasNegativePrefix = s[0] === "-";
const negativeSeconds = secondStr && secondStr[0] === "-";
const maybeNegate = num => (num && hasNegativePrefix ? -num : num);
const maybeNegate = (num, force = false) =>
num !== undefined && (force || (num && hasNegativePrefix)) ? -num : num;

@@ -155,4 +157,4 @@ return [

minutes: maybeNegate(parseInteger(minuteStr)),
seconds: maybeNegate(parseInteger(secondStr)),
milliseconds: maybeNegate(parseMillis(millisecondsStr))
seconds: maybeNegate(parseInteger(secondStr), secondStr === "-0"),
milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds)
}

@@ -159,0 +161,0 @@ ];

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

* @param {string} [opts.numberingSystem=null] - the numbering system
* @param {string} [opts.locObj=null] - an existing locale object to use
* @param {string} [opts.outputCalendar='gregory'] - the calendar

@@ -72,5 +73,5 @@ * @example Info.months()[0] //=> 'January'

length = "long",
{ locale = null, numberingSystem = null, outputCalendar = "gregory" } = {}
{ locale = null, numberingSystem = null, locObj = null, outputCalendar = "gregory" } = {}
) {
return Locale.create(locale, numberingSystem, outputCalendar).months(length);
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length);
}

@@ -87,2 +88,3 @@

* @param {string} [opts.numberingSystem=null] - the numbering system
* @param {string} [opts.locObj=null] - an existing locale object to use
* @param {string} [opts.outputCalendar='gregory'] - the calendar

@@ -93,5 +95,5 @@ * @return {[string]}

length = "long",
{ locale = null, numberingSystem = null, outputCalendar = "gregory" } = {}
{ locale = null, numberingSystem = null, locObj = null, outputCalendar = "gregory" } = {}
) {
return Locale.create(locale, numberingSystem, outputCalendar).months(length, true);
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length, true);
}

@@ -106,2 +108,3 @@

* @param {string} [opts.numberingSystem=null] - the numbering system
* @param {string} [opts.locObj=null] - an existing locale object to use
* @example Info.weekdays()[0] //=> 'Monday'

@@ -113,4 +116,4 @@ * @example Info.weekdays('short')[0] //=> 'Mon'

*/
static weekdays(length = "long", { locale = null, numberingSystem = null } = {}) {
return Locale.create(locale, numberingSystem, null).weekdays(length);
static weekdays(length = "long", { locale = null, numberingSystem = null, locObj = null } = {}) {
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length);
}

@@ -127,6 +130,10 @@

* @param {string} [opts.numberingSystem=null] - the numbering system
* @param {string} [opts.locObj=null] - an existing locale object to use
* @return {[string]}
*/
static weekdaysFormat(length = "long", { locale = null, numberingSystem = null } = {}) {
return Locale.create(locale, numberingSystem, null).weekdays(length, true);
static weekdaysFormat(
length = "long",
{ locale = null, numberingSystem = null, locObj = null } = {}
) {
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length, true);
}

@@ -133,0 +140,0 @@

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

let { s } = this,
added,
idx = 1,
next;

@@ -349,6 +349,7 @@

while (s < this.e) {
added = s.plus(dur);
const added = this.start.plus(dur.mapUnits(x => x * idx));
next = +added > +this.e ? this.e : added;
results.push(Interval.fromDateTimes(s, next));
s = next;
idx += 1;
}

@@ -433,3 +434,3 @@

if (s > e) {
if (s >= e) {
return null;

@@ -436,0 +437,0 @@ } else {

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

const VERSION = "1.26.0";
const VERSION = "1.27.0";

@@ -15,0 +15,0 @@ export {

@@ -112,3 +112,3 @@ import { formatOffset, parseZoneInfo, isUndefined, ianaRegex, objToLocalTS } from "../impl/util.js";

if (specifier) {
const match = specifier.match(/^Etc\/GMT([+-]\d{1,2})$/i);
const match = specifier.match(/^Etc\/GMT(0|[+-]\d{1,2})$/i);
if (match) {

@@ -156,4 +156,7 @@ return -60 * parseInt(match[1]);

offset(ts) {
const date = new Date(ts),
dtf = makeDTF(this.name),
const date = new Date(ts);
if (isNaN(date)) return NaN;
const dtf = makeDTF(this.name),
[year, month, day, hour, minute, second] = dtf.formatToParts

@@ -160,0 +163,0 @@ ? partsOffset(dtf, date)

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