NitheeshUnni5117 / fullcalendar-asp-net

Automatically exported from code.google.com/p/fullcalendar-asp-net
0 stars 0 forks source link

Start Date and End Date incorrect #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
the start and end date are incorrect.  
Can u let me know how to configure below parameters (QueryString["start"]) && 
(QueryString["end"]) 
)

start = start.AddSeconds(double.Parse(context.Request.QueryString["start"]));
end = end.AddSeconds(double.Parse(context.Request.QueryString["end"]));

Thaks!

Original issue reported on code.google.com by Jonas....@gmail.com on 7 Apr 2011 at 10:39

GoogleCodeExporter commented 9 years ago
I'm in the same boat.  Any help would be appreciated.  What I found is that the 
time of the start and end is 7am.  I have lots of events that begin before. So, 
the time has to be changed to 00:00:00

Original comment by paulste...@gmail.com on 1 Sep 2011 at 8:32

GoogleCodeExporter commented 9 years ago
This problem is happening because the long values being passed in the query 
string are UTC values.

To resolve this we need to reverse the ConvertToTimestamp method. Which will 
convert a UTC timestamp into a local datetime and should resolve any issues. 
Have tested and I am getting the correct date at 12:00am

Solution:

public void ProcessRequest(HttpContext context)
        {
            //...

            DateTime start = ConvertFromTimeStamp(long.Parse(context.Request.QueryString["start"]));
            DateTime end = ConvertFromTimeStamp(long.Parse(context.Request.QueryString["end"]));

            //...
        }

        private DateTime ConvertFromTimeStamp(long timestamp)
        {
            long ticks = (timestamp * 10000000) + 621355968000000000;
            return new DateTime(ticks, DateTimeKind.Utc).ToLocalTime();
        }

Original comment by Sean.B.C...@gmail.com on 22 Apr 2012 at 11:15

GoogleCodeExporter commented 9 years ago
Have attached my updated code behind file.

Original comment by Sean.B.C...@gmail.com on 22 Apr 2012 at 11:20

Attachments: