litepie-datepicker icon indicating copy to clipboard operation
litepie-datepicker copied to clipboard

Start week on Monday

Open hognevevle opened this issue 3 years ago • 5 comments

Is there a way to have Mondays appear first in the datepicker, instead of Sundays?

If not, please consider this a feature request.

hognevevle avatar Jun 23 '21 11:06 hognevevle

I can add new props for next release. thank you

kenhyuwa avatar Jun 23 '21 12:06 kenhyuwa

Hi there, it would be great, to set the first day of the week.

sdoerger avatar Sep 02 '21 17:09 sdoerger

This looks like a really promising tool - great work so far. But I also am dearly missing the option to start the week on monday. Maybe an option to manually change the underlying day.js configuration would be a solution?

bastihilger avatar Sep 29 '21 16:09 bastihilger

Great component, but I am also dearly missing the feature to set the start of the week. This puts off more than half the world. https://en.wikipedia.org/wiki/Week#Other_week_numbering_systems

It is actually provided by dayjs.localeData().firstDayOfWeek() must be either 6, 0 or 1. (Sa, Su, Mo) So, I couldn't find it yet, but all we have to do is, to offset the weekday header and the day table generation. Shouldn't be too difficult. Any ideas?

nintra avatar Aug 12 '22 08:08 nintra

right now dayjs().date() is used (datepicker.previous) if we switch it to a range base on:

// example september and first weekday: monday
dayjs.locale('de') 
const sep = dayjs('2022-09-01')

const firstDayOfMonth = sep.date(1) // Sep 1st Thursday
const firstDayOfMonthWeek = firstDayOfMonth.startOf('week') // August 29th Monday
const lastDayOfMonth = sep.endOf('month') // Sep 30th Friday
const lastDayOfMonthWeek = lastDayOfMonth.endOf('week') // October 2nd Sunday

nintra avatar Aug 12 '22 09:08 nintra