We have a scheduler application. Using this application, the user can schedule the task to be completed on 8 AM PT daily for the next 30 days. We convert time to UTC and save it in the database, since we have users from different time zones. We use the following function to convert time to UTC:
public static DateTime ToAccountLocalTime(this DateTime dt) { return TimeZoneInfo.ConvertTimeFromUtc(dt, TimeZoneInfo.FindSystemTimeZoneById("user time zone")); }
Now, if the user has scheduled the task from 8:00 to 00 every day for the next 30 days from November 1, 2012, then 30 entries will be made in the database for each of 30 days with a time set at 16:00 UTC (as returned by the method above).
The problem arose on November 4, when summer time ended. The task started at 7 a.m. instead of 8 a.m., since the scheduler service runs all the time based on UTC.
To solve this problem, we need the above method to return UTC at 16:00 for dates from November 1 to November 3 and 3 hours UTC for dates after November 4. What changes should I make to achieve this?
source share