指定区域时 Luxon DateTime fromISO 偏移量错误

Luxon DateTime fromISO wrong offset when zone is specified

当我尝试从值为“2020-03-23T00:00:00”的输入日期时间创建 DateTime 时,如果我使用区域 'Europe/Berlin',DateTime 会给出 +25偏移量改为 +1:

const isoDate = "2020-03-23T00:00:00";
const newDate = DateTime.fromISO(isoDate, {zone : 'Europe/Berlin'})

const dateToString = newDate.toString(); // logs 2020-03-23T00:00:00.000+25:00

此代码给出的时间戳为 1584831600000,即 2020 年 3 月 21 日星期六 23:00:00 UTC,应为 1584918000000 2020 年 3 月 22 日星期日 23:00:00 UTC

jsfiddle example

我哪里做错了??

您使用的是旧版本的 Luxon(1.3.2 在 jsfiddle 中),如果您升级 Luxon 版本,您的问题将得到解决。

使用版本 1.22.0 的工作片段:

const DateTime = luxon.DateTime;
const isoDate = "2020-03-23T00:00:00";
const newDate = DateTime.fromISO(isoDate, {zone : 'Europe/Berlin'})
    
const dateToString = newDate.toString();

console.log(newDate)
console.log(dateToString)
<script src="https://cdn.jsdelivr.net/npm/luxon@1.22.0/build/global/luxon.js"></script>

有关已解决 GitHub 问题的更多信息: