Repository: moment/luxon
Pull request #962 (2021-06-23 12:23:51)

Docs typo on DST weirdness
The missing DST hour should end at 999 ms, not 000 ms. Amarite?


Patch:
diff --git a/docs/zones.md b/docs/zones.md
index 57305e19..1c3bf2a0 100644
--- a/docs/zones.md
+++ b/docs/zones.md
@@ -228,7 +228,7 @@ Most of the time, DST shifts will happen without you having to do anything about
 
 ### Invalid times
 
-Some local times simply don't exist. The Spring Forward DST shift involves shifting the local time forward by (usually) one hour. In my zone, `America/New_York`, on March 12, 2017 the millisecond after 1:59:59.999 is 3:00:00.000. Thus the times between 2:00:00.000 and 2:59:59.000, inclusive, don't exist in that zone. But of course, nothing stops a user from constructing a DateTime out of that local time.
+Some local times simply don't exist. The Spring Forward DST shift involves shifting the local time forward by (usually) one hour. In my zone, `America/New_York`, on March 12, 2017 the millisecond after 1:59:59.999 is 3:00:00.000. Thus the times between 2:00:00.000 and 2:59:59.999, inclusive, don't exist in that zone. But of course, nothing stops a user from constructing a DateTime out of that local time.
 
 If you create such a DateTime from scratch, the missing time will be advanced by an hour:
 
diff --git a/scripts/bootstrap.js b/scripts/bootstrap.js
index f1b4c80b..bcb64814 100644
--- a/scripts/bootstrap.js
+++ b/scripts/bootstrap.js
@@ -4,3 +4,4 @@ global.Duration = luxon.Duration;
 global.Interval = luxon.Interval;
 global.Settings = luxon.Settings;
 global.Info = luxon.Info;
+global.IANAZone = luxon.IANAZone;
diff --git a/src/impl/regexParser.js b/src/impl/regexParser.js
index 8e4308b6..0b0297b1 100644
--- a/src/impl/regexParser.js
+++ b/src/impl/regexParser.js
@@ -267,7 +267,11 @@ const extractISOWeekTimeAndOffset = combineExtractors(
   extractISOTime,
   extractISOOffset
 );
-const extractISOOrdinalDataAndTime = combineExtractors(extractISOOrdinalData, extractISOTime);
+const extractISOOrdinalDateAndTime = combineExtractors(
+  extractISOOrdinalData,
+  extractISOTime,
+  extractISOOffset
+);
 const extractISOTimeAndOffset = combineExtractors(extractISOTime, extractISOOffset);
 
 /**
@@ -279,7 +283,7 @@ export function parseISODate(s) {
     s,
     [isoYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset],
     [isoWeekWithTimeExtensionRegex, extractISOWeekTimeAndOffset],
-    [isoOrdinalWithTimeExtensionRegex, extractISOOrdinalDataAndTime],
+    [isoOrdinalWithTimeExtensionRegex, extractISOOrdinalDateAndTime],
     [isoTimeCombinedRegex, extractISOTimeAndOffset]
   );
 }


Test patch:
diff --git a/test/datetime/regexParse.test.js b/test/datetime/regexParse.test.js
index 10f8c159..5d655887 100644
--- a/test/datetime/regexParse.test.js
+++ b/test/datetime/regexParse.test.js
@@ -435,6 +435,20 @@ test("DateTime.fromISO() accepts year-ordinalTtime", () => {
   });
 });
 
+test("DateTime.fromISO() accepts year-ordinalTtime+offset", () => {
+  const dt = DateTime.fromISO("2016-200T09:24:15.123+0600", { setZone: true });
+  expect(dt.zone.name).toBe("UTC+6");
+  expect(dt.toObject()).toEqual({
+    year: 2016,
+    month: 7,
+    day: 18,
+    hour: 9,
+    minute: 24,
+    second: 15,
+    millisecond: 123
+  });
+});
+
 test("DateTime.fromISO() accepts hour:minute:second.millisecond", () => {
   const { year, month, day } = DateTime.now();
   isSame("09:24:15.123", {