mattlewis92 / angular-calendar

A flexible calendar component for angular 15.0+ that can display events on a month, week or day view.
https://mattlewis92.github.io/angular-calendar/
MIT License
2.72k stars 863 forks source link

When [daysInWeek] is set week view always starts at Tuestay! #1563

Closed sapabg closed 2 years ago

sapabg commented 2 years ago

Describe the bug

I am using the "Responsive Week View" example at https://mattlewis92.github.io/angular-calendar/#/responsive-week-view Event there the view starts on Tuesday! It ignores weekStartsOn and it is not behaving nicely with excludeDays too!

Minimal reproduction of the problem with instructions https://stackblitz.com/edit/angular-99podh?file=demo/template.html

[weekStartsOn]="3" and it still starts on Tuesday no matter what I put here!

Screenshots

Versions

"angular-calendar": "^0.28.28",

matts-bot[bot] commented 2 years ago

Thanks so much for opening an issue! If you'd like me to give priority to answering your issue or would just like to support this project, then please consider sponsoring me

brakim commented 2 years ago

The code inside calendar-week-view.component.ts states

/**
   * The number of days in a week. Can be used to create a shorter or longer week view.
   * The first day of the week will always be the `viewDate` and `weekStartsOn` if set will be ignored
   */
  @Input() daysInWeek: number;

What you can to if you would like a 5 day week to starts on a monday is to self calculate the date for monday and pass as [viewDate] param.

//Using moment
const today = moment();
const mondayThisWeek = today.startOf('isoWeek');
sapabg commented 2 years ago

if you would like a 5 day week to starts on a monday is to self calculate the date for monday and pass as [viewDate] param.

Can you show me an example that has daysInWeek set and the week does not start on Tuesday?

brakim commented 2 years ago

if you would like a 5 day week to starts on a monday is to self calculate the date for monday and pass as [viewDate] param.

Can you show me an example that has daysInWeek set and the week does not start on Tuesday?

https://stackblitz.com/edit/angular-ivy-xhadhk?file=src/app/demo/component.ts

sapabg commented 2 years ago

if you would like a 5 day week to starts on a monday is to self calculate the date for monday and pass as [viewDate] param.

Can you show me an example that has daysInWeek set and the week does not start on Tuesday?

https://stackblitz.com/edit/angular-ivy-xhadhk?file=src/app/demo/component.ts

That worked perfectly! Thanks!