I return a list of UTC dates/times from a .Net service, formatted like so:
"2013-07-09 19:48:07 +00:00".
On the client, I convert each of these string values into a corresponding UTC-based moment, like so
var fooUtc = new moment.utc(serverDateTimeString)
On the page, there is a droop-down containing a list of time-zones that the user can change. These are tied to a collection of time-zone objects like the following:
{
id: "Central Standard Time",
label: "(UTC-06:00) Central Time (US & Canada)",
observesDaylightSavings: true,
baseUtcOffset: {
asHours: -6,
asMinutes: -360,
asText: "-06:00"
}
I then display each moment passing in the selected time-zone offset, like so:
fooUtc.local().zone(selectedTimeZone.baseUtcOffset.asMinutes).format()
However, the result does not take into account daylight savings, as the timezone data coming from .Net does not differentiate between dst and non dst offsets.
Is there a way to make this work with moment.js or the new moment-timezone bits? I think it could be possible if I could map the standard UTC offset names (ex: "Central Standard Time") to a given timezone's Olson DB identifier (ex: "America/Chicago"), but if there is an easier way, please let me know.