星期 (地區感知)
根據地區取得或設定星期幾。
這需要 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)