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 0.5.4 to 0.5.5

5

changelog.md
# Changelog
## 0.5.5
* Best-we-can-do fix for `DateTime#toLocaleString()` for fixed-offset zones when showing the zone name in the output
* Fixed `Duration#shiftTo` for unormalized Durations that need a rollup cascade
## 0.5.4

@@ -4,0 +9,0 @@

2

package.json
{
"name": "luxon",
"version": "0.5.4",
"version": "0.5.5",
"description": "Immutable date wrapper",

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

@@ -107,2 +107,4 @@ import { Util } from './impl/util';

const reverseUnits = orderedUnits.slice(0).reverse();
// clone really means "create another instance just like this one, but with these changes"

@@ -129,2 +131,25 @@ function clone(dur, alts, clear = false) {

// NB: mutates parameters
function convert(matrix, fromMap, fromUnit, toMap, toUnit) {
const conv = matrix[toUnit][fromUnit],
added = Math.floor(fromMap[fromUnit] / conv);
toMap[toUnit] += added;
fromMap[fromUnit] -= added * conv;
};
// NB: mutates parameters
function normalizeValues(matrix, vals) {
reverseUnits.reduce((previous, current) => {
if (!Util.isUndefined(vals[current])) {
if (previous) {
convert(matrix, vals, previous, vals, current);
}
return current;
} else {
return previous;
}
}, null);
}
/**

@@ -482,5 +507,6 @@ * A Duration object represents a period of time, like "2 months" or "1 day, 1 hour". Conceptually, it's just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them. They can be used on their own or in conjunction with other Luxon types; for example, you can use {@link DateTime.plus} to add a Duration object to a DateTime, producing another DateTime.

const neg = isHighOrderNegative(this.values),
dur = neg ? this.negate() : this,
shifted = dur.shiftTo(...Object.keys(this.values));
return neg ? shifted.negate() : shifted;
vals = (neg ? this.negate() : this).toObject();
normalizeValues(this.matrix, vals);
const dur = Duration.fromObject(vals);
return neg ? dur.negate() : dur;
}

@@ -507,2 +533,4 @@

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

@@ -534,6 +562,3 @@ if (units.indexOf(k) >= 0) {

if (orderedUnits.indexOf(down) > orderedUnits.indexOf(k)) {
const conv = this.matrix[k][down],
added = Math.floor(vals[down] / conv);
built[k] += added;
vals[down] -= added * conv;
convert(this.matrix, vals, down, built, k);
}

@@ -540,0 +565,0 @@ }

@@ -99,7 +99,17 @@ import { Util } from './util';

if (dt.zone.universal && this.hasIntl) {
// if we have a fixed-offset zone that isn't actually UTC,
// (like UTC+8), we need to make do with just displaying
// the time in UTC; the formatter doesn't know how to handle UTC+8
this.dt = dt.offset === 0 ? dt : DateTime.fromMillis(dt.ts + dt.offset * 60 * 1000);
// Chromium doesn't support fixed-offset zones like Etc/GMT+8 in its formatter,
// See https://bugs.chromium.org/p/chromium/issues/detail?id=364374.
// So we have to make do. Two cases:
// 1. The format options tell us to show the zone. We can't do that, so the best
// we can do is format the date in UTC.
// 2. The format options don't tell us to show the zone. Then we can adjust them
// the time and tell the formatter to show it to us in UTC, so that the time is right
// and the bad zone doesn't show up.
// We can clean all this up when Chrome fixes this.
z = 'UTC';
if (opts.timeZoneName) {
this.dt = dt;
} else {
this.dt = dt.offset === 0 ? dt : DateTime.fromMillis(dt.ts + dt.offset * 60 * 1000);
}
} else if (dt.zone.type === 'local') {

@@ -106,0 +116,0 @@ this.dt = dt;

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

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