如何在 luxon 中创建 momentLocaleData.firstDayOfWeek()?

How to create momentLocaleData.firstDayOfWeek() in luxon?

稍后您可以拨打电话:

momentLocaleData.firstDayOfWeek()

是否有可能在 Luxon 中获得相同的功能?

我担心,在最新版本 (1.3.3) 中,这是不可能的,因为 docs 指出:

Basic internationalization. Luxon doesn't have internationalized strings in its code; instead it relies on the hosts implementation of the Intl API. This includes the very handy toLocaleString. Most browsers and recent versions of Node support this.

此外,使用 Luxon,您始终将星期一作为一周的第一天,如您在以下代码段中所见:

// Luxon
const DateTime = luxon.DateTime;
console.log( DateTime.local().setLocale('fr-CA').startOf('week').toISO() );
// Moment.js
console.log( moment().locale('fr-ca').startOf('week').format() );
<script src="https://moment.github.io/luxon/global/luxon.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment-with-locales.min.js"></script>

请注意 startOf 文档中没有 'week' 参数:

"Set" this DateTime to the beginning of a unit of time.

Params:

Name    Type    Attribute   Description
unit    string              The unit to go to the beginning of. Can be 'year', 'month', 'day', 'hour', 'minute', 'second', or 'millisecond'.