ロケール対応の曜日
ロケールに従って曜日を取得または設定します。
これは、Weekday
プラグインが動作するために必要です。
ロケールで日曜日が週の最初の日として設定されている場合、dayjs().weekday(0)
は日曜日になります。月曜日が週の最初の日である場合、dayjs().weekday(0)
は月曜日になります。
dayjs.extend(weekday)
// when Sunday is the first day of the week
dayjs().weekday(-7); // last Sunday
dayjs().weekday(7); // next Sunday
// when Monday is the first day of the week
dayjs().weekday(-7) // last Monday
dayjs().weekday(7) // next Monday
// when Sunday is the first day of the week
dayjs().weekday(-5) // last Tuesday (5th day before Sunday)
dayjs().weekday(5) // next Friday (5th day after Sunday)