mattlewis92/angular-bootstrap-calendar

How can I set the calendar's timezone?

wootwoot1234 opened this issue · 2 comments

I posted this question on stackoverflow, as suggested, but haven't gotten any responses so I thought I would go to the source, I hope that's ok.

I'm using angular-bootstrap-calendar to display the calendar of an short term rental listing. Currently, the calendar displays the dates in the timezone of the browser but the user isn't always in the same timezone as the listing they are managing.

How can I set the calendar's timezone so that it shows the dates in the timezone of the listing and not the timezone of the bowser?

How do you acquire the data for calendar? Do you include that in the JS file, or do you use some kind of API?

To do this you would need to use the moment timezone plugin to manipulate the dates passed to the calendar:

const userTimezone = 'America/Los_Angeles';
vm.events = [
  {
        title: 'An event',
        color: calendarConfig.colorTypes.warning,
        startsAt: moment().tz(userTimezone).startOf('week').subtract(2, 'days').add(8, 'hours').toDate(),
        endsAt: moment().tz(userTimezone).startOf('week').add(1, 'week').add(9, 'hours').toDate()
  }
];