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 0.4.0 to 0.5.0

7

changelog.md
# Changelog
## 0.5.0
* `isBefore()` returns true for the end of the interval, consistent with being half-open
* `zoneName` now rturns `null` for invalid DateTimes
* Added quarter support
* Adding a month to Jan 31 gives Feb 28/29
## 0.4.0

@@ -4,0 +11,0 @@

2

package.json
{
"name": "luxon",
"version": "0.4.0",
"version": "0.5.0",
"description": "Immutable date wrapper",

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

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

const INVALID = 'Invalid Duration';
const INVALID = 'Invalid Duration',
UNPARSABLE = 'unparsable';

@@ -41,2 +42,10 @@ // unit conversion constants

},
quarters: {
months: 3,
weeks: 13,
days: 91,
hours: 91 * 24,
minutes: 91 * 24 * 60,
milliseconds: 91 * 24 * 60 * 60 * 1000
},
months: {

@@ -66,2 +75,11 @@ weeks: 4,

},
quarters: {
months: 3,
weeks: daysInYearAccurate / 28,
days: daysInYearAccurate / 4,
hours: daysInYearAccurate * 24 / 4,
minutes: daysInYearAccurate * 24 * 60 / 4,
seconds: daysInYearAccurate * 24 * 60 * 60 / 4,
milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000 / 4
},
months: {

@@ -82,2 +100,3 @@ weeks: daysInMonthAccurate / 7,

'years',
'quarters',
'months',

@@ -171,2 +190,3 @@ 'weeks',

* @param {number} obj.years
* @param {number} obj.quarters
* @param {number} obj.months

@@ -206,4 +226,9 @@ * @param {number} obj.weeks

static fromISO(text, opts) {
const obj = Object.assign(RegexParser.parseISODuration(text), opts);
return Duration.fromObject(obj);
const [parsed] = RegexParser.parseISODuration(text);
if (parsed) {
const obj = Object.assign(parsed, opts);
return Duration.fromObject(obj);
} else {
return Duration.invalid(UNPARSABLE);
}
}

@@ -234,2 +259,4 @@

years: 'years',
quarter: 'quarters',
quarters: 'quarters',
month: 'months',

@@ -326,3 +353,3 @@ months: 'months',

if (norm.years > 0) s += norm.years + 'Y';
if (norm.months > 0) s += norm.months + 'M';
if (norm.months > 0 || norm.quarters > 0) s += norm.months + norm.quarters * 3 + 'M';
if (norm.days > 0 || norm.weeks > 0) s += norm.days + norm.weeks * 7 + 'D';

@@ -559,2 +586,10 @@ if (norm.hours > 0 || norm.minutes > 0 || norm.seconds > 0 || norm.milliseconds > 0) s += 'T';

/**
* Get the quarters.
* @return {number}
*/
get quarters() {
return this.isValid ? this.values.quarters || 0 : NaN;
}
/**
* Get the months.

@@ -561,0 +596,0 @@ * @return {number}

@@ -328,2 +328,8 @@ import { English } from './english';

return this.num(dt.ordinal, 3);
case 'q':
// like 1
return this.num(dt.quarter);
case 'qq':
// like 01
return this.num(dt.quarter, 2);
default:

@@ -330,0 +336,0 @@ return maybeMacro(token);

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

/*
This file handles parsing for well-specified formats. Here's how it works:
* This file handles parsing for well-specified formats. Here's how it works:
* Two things go into parsing: a regex to match with and an extractor to take apart the groups in the match.

@@ -15,3 +15,3 @@ * An extractor is just a function that takes a regex match array and returns a { year: ..., month: ... } object

* Some extractions are super dumb and simpleParse and fromStrings help DRY them.
*/
*/

@@ -118,3 +118,3 @@ function combineRegexes(...regexes) {

return {
return [ {
years: parseInt(yearStr),

@@ -127,3 +127,3 @@ months: parseInt(monthStr),

seconds: parseInt(secondStr)
};
} ];
}

@@ -130,0 +130,0 @@

@@ -75,2 +75,7 @@ import { Duration } from '../duration';

// x % n but takes the sign of n instead of x
static floorMod(x, n) {
return x - n * Math.floor(x / n);
}
static padStart(input, n = 2) {

@@ -100,6 +105,9 @@ return ('0'.repeat(n) + input).slice(-n);

static daysInMonth(year, month) {
if (month === 2) {
return Util.isLeapYear(year) ? 29 : 28;
const modMonth = Util.floorMod(month - 1, 12) + 1,
modYear = year + (month - modMonth) / 12;
if (modMonth === 2) {
return Util.isLeapYear(modYear) ? 29 : 28;
} else {
return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][modMonth - 1];
}

@@ -106,0 +114,0 @@ }

@@ -206,3 +206,3 @@ import { Util } from './impl/util';

if (!this.isValid) return false;
return this.e.plus(1) < dateTime;
return this.e <= dateTime;
}

@@ -209,0 +209,0 @@

@@ -45,3 +45,7 @@ import { LocalZone } from './zones/localZone';

static set defaultZoneName(z) {
defaultZone = Util.normalizeZone(z);
if (!z) {
defaultZone = null;
} else {
defaultZone = Util.normalizeZone(z);
}
}

@@ -48,0 +52,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

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