In the UK, the clocks went back 1 hour on the 26th of October, 2014 at 02:00 AM. In this case, everybody in the UK observed the time between 01:00 to 01:59 twice at that day.
Assume that I am have a .NET software application where the date and time is very important on the specific time zone. In this case, what should I infer when I see 26th of October 01:00 inside my data storage system? Should I be storing the time zone such as BST and GMT, or should I be storing the offset values instead?
I am generally confused about what to do in this cases (hopefully I'm not the only confused person :D). The reason is the fact that a time zone abbreviation can have multiple meanings like BST:
- Bangladesh Standard Time (Standard Time)
- British Summer Time / British Daylight Time (Daylight Saving Time)
What is the best practice for these cases especially in .NET applications (both BCL DateTime value types and NodaTime solutions would be appreciated)?
Edit 1
There are a few suggestions for persisting in UTC. However, imagine that, I need to know about time zone in this application. An example would be flight ticket application. You would take off from one time zone and land in on another. Even if we can get away with converting the date and time to UTC and storing the time zone nearby, I'm still unable to find the proper solution for ambiguous times which is the whole point of this question. The below perfectly works (BCL value types, not NodaTime):
static void ConvertToAndFromUtcCorrectly()
{
const string ukTimeZoneId = "GMT Standard Time";
TimeZoneInfo ukTimeZone = TimeZoneInfo.FindSystemTimeZoneById(ukTimeZoneId);
// 3/30/2014 2:00:00 AM (BST)
DateTime aDateTimeInDst = new DateTime(2014, 3, 30, 2, 0, 0);
// 3/30/2014 1:00:00 AM (UTC)
DateTime aDateTimeInDstUtc = TimeZoneInfo.ConvertTimeToUtc(aDateTimeInDst, ukTimeZone);
// 3/30/2014 2:00:00 AM (BST)
DateTime backToUkTime = TimeZoneInfo.ConvertTimeFromUtc(aDateTimeInDstUtc, ukTimeZone);
}
The below one fails miserably:
static void ConvertToAndFromUtcWrongly()
{
const string ukTimeZoneId = "GMT Standard Time";
TimeZoneInfo ukTimeZone = TimeZoneInfo.FindSystemTimeZoneById(ukTimeZoneId);
// 10/26/2014 1:00:00 AM (This is meant to be BST, not GMT)
DateTime ambiguousUkDateTime = new DateTime(2014, 10, 26, 1, 0, 0);
// 10/26/2014 1:00:00 AM (UTC)
DateTime ambiguousUkDateTimeUtc = TimeZoneInfo.ConvertTimeToUtc(ambiguousUkDateTime, ukTimeZone);
// 10/26/2014 1:00:00 AM (WHAT?)
DateTime backToUkTime = TimeZoneInfo.ConvertTimeFromUtc(ambiguousUkDateTimeUtc, ukTimeZone);
}
Edit 2
In order to be more specific with my question here: According to my above sample, how would you store 26th of October, 2014 01:00 AM (which is an ambiguous time) in a data storage system and read/write this data in a .NET application?