gpt4 book ai didi

luxon - 如何在吕宋岛创建时刻 LocaleData.firstDayOfWeek()?

转载 作者:行者123 更新时间:2023-12-03 16:24:45 25 4
gpt4 key购买 nike

您可以立即调用:
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>


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

"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'.

关于luxon - 如何在吕宋岛创建时刻 LocaleData.firstDayOfWeek()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50350110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com