twinssbc / AngularJS-ResponsiveCalendar

A pure AngularJS responsive calendar directive
http://twinssbc.github.io/AngularJS-ResponsiveCalendar/demo/
MIT License
112 stars 77 forks source link

Event is appearing in two days for an all day event #51

Closed captainmorgan0 closed 8 years ago

captainmorgan0 commented 8 years ago

I have an event with a startTime set to Wed May 18 2016 00:00:00 GMT+1000 (AUS Eastern Standard Time) and the endTime set to Wed May 18 2016 23:59:00 GMT+1000 (AUS Eastern Standard Time). When the calendar loads, the all day event is showing on May 17 and 18. I have tried this with the allday flag set to true and false and I get the same result

twinssbc commented 8 years ago

@captainmorgan0 As I documented in README, you need to use UTC date for all day events.

If allDay is set to true, the startTime has to be as a UTC date which time is set to 0:00 AM, because in an allDay event, only the date is considered, the exact time or timezone doesn't matter.
For example, if an allDay event starting from 2014-05-09, then startTime is

var startTime = new Date(Date.UTC(2014, 4, 8));
captainmorgan0 commented 8 years ago

Thanks. That works, and the event shows when viewing by month. However, I don't see the event in week or day view.

twinssbc commented 8 years ago

@captainmorgan0 You can't see the allDay events or even normal events? Is the view rendered ok? If so, could you check if the events are passed correctly to the selected date range?

captainmorgan0 commented 8 years ago

In month view, I can see normal events and all day events. In week view and day view I can see normal events, but I can't see all day events.

captainmorgan0 commented 8 years ago

In you documentation, you say the startTime has to be as a UTC date which time is set to 0:00 AM, However, If I do console.log(new Date(Date.UTC(2014, 4, 8)));, I get the output "Thu May 08 2014 10:00:00 GMT+1000 (AUS Eastern Standard Time)", the time is no 0:00 AM. Does your example need to specify the time as well? Also, that date is not May 8.

twinssbc commented 8 years ago

You don't need to specify the time part. The local time Thu May 08 2014 10:00:00 GMT+1000 (AUS Eastern Standard Time) is exactly 2014-05-08 00:00 AM in UTC time. Also in Date.UTC method, month parameter is 0-11. That's why you pass 4, but actually it's May.

captainmorgan0 commented 8 years ago

My bad. My css was hiding the all day event in the day and week view.