In moment you can call:
momentLocaleData.firstDayOfWeek()
Is it possible to get the same functionality in Luxon?
I fear that, in the lastest version (1.3.3
), it is not possible since docs states:
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.
Moreover, using Luxon, you always get Monday as the first day of the week, as you can see in the following snippet:
// 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>
Please note that there is no 'week'
parameter in startOf
docs:
"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'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With