星期(区域设置感知)
根据区域设置获取或设置星期几。
¥Gets or sets the day of the week according to the locale.
This requires the
Weekday
plugin to work
如果区域设置将星期日指定为一周的第一天,则 dayjs().weekday(0)
将是星期日。如果星期一是一周的第一天,则 dayjs().weekday(0)
将是星期一。
¥If the locale assigns Sunday as the first day of the week, dayjs().weekday(0)
will be Sunday. If Monday is the first day of the week, dayjs().weekday(0)
will be Monday.
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)