I have a javascript application which receives data from ASP.NET WebService in JSON format. My application has a lot of manipulations with dates which it also receives from WebService.
WebService stores all dates in EST timezone and sends them in such format:
{"Date":"\/Date(1319205600000+0300)\/"}
to my javascript application.
On the client side I should display all dates also in EST timezone irrespectively of browser's timezone. So if I receive from the server the representation of:
10/21/2011 10:00
I should display exactly the same time to the user.
So to convert dates I do something like this:
function convert_date(millisec) {
var date = new Date(millisec),
local_offset = date.getTimezoneOffset(),
server_offset = -5 * 60, //EST offset
diff = (local_offset + server_offset) * 60000;
return new Date(millisec + diff);
}
But the point is that server_offset not always should be -5. It can be -4 depending on DST value. I've tried to do server_offset = (date.isDST() ? -4 : -5) * 60 instead but I haven't found any solution for capturing isDST() which works fine for all the local client timezones. Most of them work fine for that local browser's timezone which has the same value of DST as EST timezone but would fail in the case of GMT+5:30 timezone for example.
So are there any way to determine whether DST would be applied for some specific date in EST timezone from javascript?
Or maybe I've missed something?