Luxon 无法解析此日期格式

Luxon is failing to parse this date format

我想弄清楚为什么 luxon 无法解析此日期格式。

这是我的原始值:2019-04-23T23:15:07.910Z

这是什么格式(好像是iso格式)

代码片段:

console.log('document.lastUpdatedAt = ', document.lastUpdatedAt)

const fromISO = DateTime.fromISO(document.lastUpdatedAt)
console.log('fromISO = ', fromISO)

const fromSQL = DateTime.fromSQL(document.lastUpdatedAt)
console.log('fromSQL = ', fromSQL)

const fromHTTP = DateTime.fromHTTP(document.lastUpdatedAt)
console.log('fromHTTP = ', fromHTTP)

上面代码片段的输出:

document.lastUpdatedAt =  2019-04-23T23:15:07.910Z
test =  test
fromISO =  DateTime {
  ts: 1556062543882,
  _zone: LocalZone {},
  loc:
   Locale {
     locale: 'en',
     numberingSystem: null,
     outputCalendar: null,
     intl: 'en',
     weekdaysCache: { format: {}, standalone: {} },
     monthsCache: { format: {}, standalone: {} },
     meridiemCache: null,
     eraCache: {},
     specifiedLocale: null,
     fastNumbersCached: null },
  invalid:
   Invalid {
     reason: 'unparsable',
     explanation:
      'the input "Tue Apr 23 2019 16:15:07 GMT-0700 (Pacific Daylight Time)" can\'t be parsed as ISO 8601' },
  weekData: null,
  c: null,
  o: null,
  isLuxonDateTime: true }
fromSQL =  DateTime {
  ts: 1556062543889,
  _zone: LocalZone {},
  loc:
   Locale {
     locale: 'en',
     numberingSystem: null,
     outputCalendar: null,
     intl: 'en',
     weekdaysCache: { format: {}, standalone: {} },
     monthsCache: { format: {}, standalone: {} },
     meridiemCache: null,
     eraCache: {},
     specifiedLocale: null,
     fastNumbersCached: null },
  invalid:
   Invalid {
     reason: 'unparsable',
     explanation:
      'the input "Tue Apr 23 2019 16:15:07 GMT-0700 (Pacific Daylight Time)" can\'t be parsed as SQL' },
  weekData: null,
  c: null,
  o: null,
  isLuxonDateTime: true }
fromHTTP =  DateTime {
  ts: 1556062543890,
  _zone: LocalZone {},
  loc:
   Locale {
     locale: 'en',
     numberingSystem: null,
     outputCalendar: null,
     intl: 'en',
     weekdaysCache: { format: {}, standalone: {} },
     monthsCache: { format: {}, standalone: {} },
     meridiemCache: null,
     eraCache: {},
     specifiedLocale: null,
     fastNumbersCached: null },
  invalid:
   Invalid {
     reason: 'unparsable',
     explanation: 'the input "[object Object]" can\'t be parsed as HTTP' },
  weekData: null,
  c: null,
  o: null,
  isLuxonDateTime: true }

啊,刚刚明白了。结果 2019-04-23T23:15:07.910Z 实际上是一个 javascript 日期对象。

这意味着我需要做 const fromJSDate = DateTime.fromJSDate(document.lastUpdatedAt)