search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Wrong Start Time and End Time for a event in Week View

Asked by Raghav
14 years ago.


1. I have a week view from Sunday to Saturday. I have hard coded the start date as "2007-01-07" as it is a sunday used it to calculate the other six days in the week.

2. I built events and displayed it correctly in the week view.

3. When I click on the event for a particular day spanning from (0:00 to 23:59) it is giving me a wrong start time and end time in my javascript code (The start time in this case seems to have a date for previous day and a wrong time. The end time has correct date but a wrong time). I noted that the issue happens only when the server is in "Eastern Standard Time Daylight Setting" time zone. I checked the behavior in your trial samples and the sample has the same issue. Please let me know if there is a fix for this issue.

4. When it is working correctly in other times zonesthe start time and end time have correct datebut havewrong time.

I am using ver 4.6.1380.0



Comment posted by Dan Letecky
14 years ago.
Because of the time zone issues (specifically, IE automatically switches time zones using simple operations like newDate.setDate(date.getDate() + ticks) while FF does not) all the dates should be handled using getUTCxxx() functions: getUTCDay(), getUTCHours() etc. should give you the correct time.

All dates on the client side of DayPilot are hold as GMT values. E.g. If your starting datetime is "2008-05-12 05:00:00" it will be passed as "2008-05-12 05:00:00 +0000". The functions of the JaavScript Date object work with the current time zone of the browser, i.e. if you use alert(e.start()) it will show a wrong date (the offset actually equals to the time zone shift). But if you use alert(e.start().toGMTString()) you will get the correct date and time.

I plan to introduce DayPilot's own Date client-side object. The databases usually don't attach any time zone info to the DateTime values and the JavaScript automatic conversion complicates things here.
Comment posted by Dave Griffiths
14 years ago.

We also have had a problem with date/time issues in DayPilot. The confusion lies in the fact that the server side code and what is rendered assumes on the calendar is local time (i.e in our case BST/GMT+1), but daypilots client/javascripttimes get calculated with the localtime with the timezone offset removed (i.e. modified to UTC - +0000), but without adjusting the time for UTC. This makes all actions (like timerangeselect) pass the wrong date/time, offset by the difference between server time and the clients local time.

i.e. during BST/GMT+1, our calendar starts atmidnightor 12AM BST, which is 11PM UTC/GMT the prevous day, the way daypilot calculates it's dates for client side code uses 00:00:00 +0000 as the start, so selecting a timerange say from midnight to 1am, will pass a range of 00:00:00 +0000 to 01:00:00 +0000. This is wrong. When Javascript parses the date and converts it to a date object, it willbe converted to the clients local time zone .. 00:00:00 +0000 on my machine (in BST) will convert to the Date(01:00:00 +0100) .. I didn't select 1am BST, I selected midnight BST.

In order to correct this, I've modified the DOM after day pilot renders. I've updated the columns/event dates in the DOM to use +0100 (or the offset on our server) instead of +0000.I've done this by using a javascript framework (ExtJs) to find the calendars column headers (where thestarting date/time seem to be calculated from), and simply replacing the +0000 with +0100 (or whatever your data/server/users local time is), using a regex. I've also done the same across all client-side dates/times which also have the incorrect time (right time, wrong timezone). DayPilot now works perfectly, and as we'd expect - all client-side code works with the correct/local time, and we can work happily with local date/times on the server.

After a long time looking at this issue I think as I have it it's the correct behaviour -is there any chance that this might get fixed in a release?

Comment posted by Dan Letecky
14 years ago.
DayPilot used to operate with the local time in the past but during DayPilotScheduler the problem with the calculations appeared so all controls are now working with GMT values.

I understand that it's confusing. However, it's not just a matter of switching back to local timezone. I will need to introduce a special JavaScript object that will wrap the Date object and expose the right behavior.
Comment posted by
14 years ago.

how to get short date from daypilot complex date like sep 01, 11:11:11 2008

to 11/1/2008 from JS daypilot function ?

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.