Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to start the week on monday #20

Closed
RichardLindhout opened this issue Oct 6, 2020 · 15 comments · Fixed by #389
Closed

Make it possible to start the week on monday #20

RichardLindhout opened this issue Oct 6, 2020 · 15 comments · Fixed by #389
Labels

Comments

@RichardLindhout
Copy link
Member

Starts Monday or Sunday
According to international standard ISO 8601, Monday is the first day of the week. It is followed by Tuesday, Wednesday, Thursday, Friday, and Saturday. Sunday is the 7th and last day of the week.

Although this is the international standard, several countries, including the United States and Canada, consider Sunday as the start of the week.

Source: https://www.timeanddate.com/calendar/days/#:~:text=Starts%20Monday%20or%20Sunday,last%20day%20of%20the%20week

@RichardLindhout RichardLindhout added the enhancement New feature or request label Oct 6, 2020
@ravi-poonia
Copy link

@RichardLindhout How are planning to handle this? I can assist you with this on my free time. Can you describe the solution if you have one in mind.

@RichardLindhout
Copy link
Member Author

It's fairly complex I think

Layout can be changed here:
https://github.com/web-ridge/react-native-paper-dates/blob/master/src/DayNames.tsx

But also the grid need to be generated another way

https://github.com/web-ridge/react-native-paper-dates/blob/master/src/Month.tsx#L117

@Precho
Copy link

Precho commented Dec 23, 2020

Hello, are you working on it ? Is there any possibilty to set Monday as a first day of a week ?

@RichardLindhout
Copy link
Member Author

Not yet. But it'll be added in the future

@Precho
Copy link

Precho commented Jan 6, 2021

Do you know exactly when? I wonder if it is a matter of weeks. I'm looking forward :)

@RichardLindhout
Copy link
Member Author

I'm still thinking about the best approach to this as there are some hard edge cases. E.g if the month starts on sunday the grid has a different outcome when the day starts on monday and the grid need to be calculated up front. I have however change this in the latest version so I could do more calculations. I think it will be added within 2 months but it is not a priority for one of our customers right now so I'm not sure when exactly. I have disabled some week days in my app e.g. Sunday, Saturday with disableWeekDays

@nandorojo
Copy link
Contributor

In the US, week typically starts on Sunday. So maybe this should be an option if it’s going to change.

@RichardLindhout RichardLindhout changed the title Make week start on monday Make it possible to start the week on monday Mar 10, 2021
@RichardLindhout
Copy link
Member Author

@nandorojo I will :)

@Isaccobosio
Copy link

Isaccobosio commented Jan 20, 2022

I found a salution.. or something
In Month.tsx I put this code

const isFirstWeek = weekGrid === 0
const realDayIndex = emptyDays - dayIndex -1 // put a -1
const beforeWeekDay = isFirstWeek && realDayIndex > 0
const dayOfMonth = weekGrid * 7 + dayIndex +1 - emptyDays + 1 // put a +1 after dayIndex

And for change name of week day (I mean to make week start with monday) I put this

const weekdays = [
  new Date(2020, 7, 3),
  new Date(2020, 7, 4),
  new Date(2020, 7, 5),
  new Date(2020, 7, 6),
  new Date(2020, 7, 7),
  new Date(2020, 7, 8),
  new Date(2020, 7, 9),
]

onDayNames.tsx
Hope it could be useful

@RichardLindhout
Copy link
Member Author

This works but the height of the month needs to be correct also so that is a hard thing I think

@JB712
Copy link

JB712 commented Jan 5, 2023

Any update on this @RichardLindhout ?

@kacper-cyra
Copy link

I found a salution.. or something In Month.tsx I put this code

const isFirstWeek = weekGrid === 0
const realDayIndex = emptyDays - dayIndex -1 // put a -1
const beforeWeekDay = isFirstWeek && realDayIndex > 0
const dayOfMonth = weekGrid * 7 + dayIndex +1 - emptyDays + 1 // put a +1 after dayIndex

And for change name of week day (I mean to make week start with monday) I put this

const weekdays = [
  new Date(2020, 7, 3),
  new Date(2020, 7, 4),
  new Date(2020, 7, 5),
  new Date(2020, 7, 6),
  new Date(2020, 7, 7),
  new Date(2020, 7, 8),
  new Date(2020, 7, 9),
]

onDayNames.tsx Hope it could be useful

To fix wrong number of weeks in month problem and still have the Monday as the first day of the week I have reversed yours changes in Month.tsx and changed getFirstDayOfMonth function in dateUtils.tsx to:

export function getFirstDayOfMonth({
  year,
  month,
}: {
  year: number
  month: number
}): number {
  const numberDayWeek = [6, 0, 1, 2, 3, 4, 5]
  const dayWeek = new Date(year, month, 1).getDay()

  return numberDayWeek[dayWeek]
}

From what I see it affects only UI and for me it works good enough 😄

@budwol
Copy link

budwol commented Aug 20, 2023

please make it possible.

@iM-GeeKy
Copy link
Collaborator

PRs are welcome!

@tm00-git
Copy link

Why it is low priority? Unable to properly localize this component for my app used in europe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants