3

I am using this calendar https://github.com/mattlewis92/angular-bootstrap-calendar for showing events and time slots for people all over the world. During sign up, every user has to set his timezone and then my application uses this timezone for further date computation rather than client machine timezone.

The problem is that when I make user timezone default using moment.tz.setDefault(timezone) and change the machine's timezone, the calendar calculates dates wrongly.

Here is my excerpt of my code:

moment.tz.setDefault($rootScope.timezone)
vm.calendarView = 'month';
vm.viewDate = moment().startOf('month').toDate(); 
vm.cellIsOpen = true;

Attached is the screenshot:

[Screenshot]

enter image description here

You can see that user's timezone is currently Asia/Karachi +5 and my machine's timezone is Beijing +8. Today's date is 8 September and the day is Friday, but on the calendar 8 September is showing as a Saturday instead of Friday.

4

2 回答 2

1

mwl-calander 不提供时区支持,你可以使用完整的日历

https://fullcalendar.io/ 演示 https://fullcalendar.io/js/fullcalendar-2.9.1/demos/timezones.html

它的角度指令可以在 https://github.com/angular-ui/ui-calendar找到

于 2017-09-13T07:30:39.953 回答
1

这个特定的 UI 控件似乎不支持选择时区。简单地使用moment.tz.setDefault是不够的,因为控件在内部和外部 API 中所做的一切都在使用Date对象,这些对象不能代表任意时区。换句话说,该控件的作者必须删除所有.toDate()调用并使用Moment对象作为控件中的原语而不是Date对象。这对他们来说将是一个突破性的变化。

我建议在该项目的 GitHub 存储库中提交问题,并参考此页面。

于 2017-09-08T20:10:52.100 回答