diff --git a/package-lock.json b/package-lock.json index 2e0ef599c..048018b1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "luxon", - "version": "2.5.0", + "version": "2.5.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "luxon", - "version": "2.5.0", + "version": "2.5.2", "license": "MIT", "devDependencies": { "@babel/core": "^7.18.6", diff --git a/package.json b/package.json index 6a6bd529e..a1d794fc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "luxon", - "version": "2.5.0", + "version": "2.5.2", "description": "Immutable date wrapper", "author": "Isaac Cambron", "keywords": [ diff --git a/src/impl/regexParser.js b/src/impl/regexParser.js index 43689a454..6b4311e08 100644 --- a/src/impl/regexParser.js +++ b/src/impl/regexParser.js @@ -5,7 +5,7 @@ import { parseMillis, ianaRegex, isUndefined, - parseFloating, + parseFloating } from "./util.js"; import * as English from "./english.js"; import FixedOffsetZone from "../zones/fixedOffsetZone.js"; @@ -27,7 +27,7 @@ function combineRegexes(...regexes) { } function combineExtractors(...extractors) { - return (m) => + return m => extractors .reduce( ([mergedVals, mergedZone, cursor], ex) => { @@ -91,7 +91,7 @@ function extractISOYmd(match, cursor) { const item = { year: int(match, cursor), month: int(match, cursor + 1, 1), - day: int(match, cursor + 2, 1), + day: int(match, cursor + 2, 1) }; return [item, null, cursor + 3]; @@ -102,7 +102,7 @@ function extractISOTime(match, cursor) { hours: int(match, cursor, 0), minutes: int(match, cursor + 1, 0), seconds: int(match, cursor + 2, 0), - milliseconds: parseMillis(match[cursor + 3]), + milliseconds: parseMillis(match[cursor + 3]) }; return [item, null, cursor + 4]; @@ -126,12 +126,20 @@ const isoTimeOnly = RegExp(`^T?${isoTimeBaseRegex.source}$`); // ISO duration parsing -const isoDuration = - /^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/; +const isoDuration = /^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/; function extractISODuration(match) { - const [s, yearStr, monthStr, weekStr, dayStr, hourStr, minuteStr, secondStr, millisecondsStr] = - match; + const [ + s, + yearStr, + monthStr, + weekStr, + dayStr, + hourStr, + minuteStr, + secondStr, + millisecondsStr + ] = match; const hasNegativePrefix = s[0] === "-"; const negativeSeconds = secondStr && secondStr[0] === "-"; @@ -148,8 +156,8 @@ function extractISODuration(match) { hours: maybeNegate(parseFloating(hourStr)), minutes: maybeNegate(parseFloating(minuteStr)), seconds: maybeNegate(parseFloating(secondStr), secondStr === "-0"), - milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds), - }, + milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds) + } ]; } @@ -165,7 +173,7 @@ const obsOffsets = { MDT: -6 * 60, MST: -7 * 60, PDT: -7 * 60, - PST: -8 * 60, + PST: -8 * 60 }; function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) { @@ -174,7 +182,7 @@ function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, month: English.monthsShort.indexOf(monthStr) + 1, day: parseInteger(dayStr), hour: parseInteger(hourStr), - minute: parseInteger(minuteStr), + minute: parseInteger(minuteStr) }; if (secondStr) result.second = parseInteger(secondStr); @@ -189,8 +197,7 @@ function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, } // RFC 2822/5322 -const rfc2822 = - /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/; +const rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/; function extractRFC2822(match) { const [ @@ -205,7 +212,7 @@ function extractRFC2822(match) { obsOffset, milOffset, offHourStr, - offMinuteStr, + offMinuteStr ] = match, result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr); @@ -224,19 +231,16 @@ function extractRFC2822(match) { function preprocessRFC2822(s) { // Remove comments and folding whitespace and replace multiple-spaces with a single space return s - .replace(/\([^)]*\)|[\n\t]/g, " ") + .replace(/\([^()]*\)|[\n\t]/g, " ") .replace(/(\s\s+)/g, " ") .trim(); } // http date -const rfc1123 = - /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/, - rfc850 = - /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/, - ascii = - /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/; +const rfc1123 = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/, + rfc850 = /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/, + ascii = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/; function extractRFC1123Or850(match) { const [, weekdayStr, dayStr, monthStr, yearStr, hourStr, minuteStr, secondStr] = match, diff --git a/src/luxon.js b/src/luxon.js index 2f468ef5d..77f35062c 100644 --- a/src/luxon.js +++ b/src/luxon.js @@ -9,7 +9,7 @@ import InvalidZone from "./zones/invalidZone.js"; import SystemZone from "./zones/systemZone.js"; import Settings from "./settings.js"; -const VERSION = "2.5.0"; +const VERSION = "2.5.2"; export { VERSION,