Angular-calendar: Wrong week date range in calendar header when using week start as middle day of week

Created on 24 Jul 2019  路  7Comments  路  Source: mattlewis92/angular-calendar

Describe the bug

I am using below code to show week date range in week view header.

  <div class="col-md-4 text-center">
    <h3>{{ viewDate | calendarDate: view + 'ViewTitle':locale }}</h3>
  </div>

I have configured week view as below.

<mwl-calendar-week-view [hourSegments]="2" [weekStartsOn]="4" [viewDate]="viewDate"
    [events]="events" [dayStartHour]="6" [dayEndHour]="18">
</mwl-calendar-week-view>

Week start is Thursday and end is Wednesday. Week view calendar show the correct week start and end dates. But header component shows wrong date range for week.

Week range should be Jul 18 - Jul 24, 2019. But, as in the below image it displays as Jul 21 - Jul 27, 2019

How can I fix this?

Minimal reproduction of the problem with instructions

Here is the Stackblitz

Screenshots


image

Versions

  • @angular/core: 6.1.7
  • angular-calendar: 0.27.14
  • Browser name and version: Google Chrome Version 75.0.3770.142 (Official Build) (64-bit)
documentation

Most helpful comment

You need to pass the weekStartsOn as an argument to the calendarDate pipe, so that it knows about it:

<h3>{{ viewDate | calendarDate:(view + 'ViewTitle'):'en':4 }}</h3>

I'll update the docs to make this more clear as it's come up a few times now and it's quite confusing.

All 7 comments

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 supporting me on Patreon

It would be helpful if you could make a Stackblitz reproducing the issue. You can do so by starting with any of the demo pages, modifying it, and then saving a fork on Stackblitz

@JaxonWright Here is the Stackblitz

The issue is probably somewhere in the getWeekViewPeriod method seen here. I don't know exactly where, though. Will probably look into it more later. Thoughts @mattlewis92 ?

You need to pass the weekStartsOn as an argument to the calendarDate pipe, so that it knows about it:

<h3>{{ viewDate | calendarDate:(view + 'ViewTitle'):'en':4 }}</h3>

I'll update the docs to make this more clear as it's come up a few times now and it's quite confusing.

Thanks for the update. With this modification, now show the correct week date range in the header.

Awesome! Gonna leave this open for now as a reminder to myself to update the docs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chaouiy picture chaouiy  路  3Comments

Seb69 picture Seb69  路  3Comments

agilob picture agilob  路  3Comments

Novabllast picture Novabllast  路  3Comments

fmoessle picture fmoessle  路  5Comments