<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Designing "Time Zone conversions"</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx</link><description>The BCL Team has been spending a lot of time investigating on how to provide richer support for Time Zones. As the PM who owns System.DateTime, I am tasked with figuring out the scenarios that are important for our developers whose customers needs to</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title> Kathy Kam Designing Time Zone conversions | debt settlement program</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#9787473</link><pubDate>Fri, 19 Jun 2009 16:35:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9787473</guid><dc:creator> Kathy Kam Designing Time Zone conversions | debt settlement program</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://edebtsettlementprogram.info/story.php?id=22783"&gt;http://edebtsettlementprogram.info/story.php?id=22783&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9787473" width="1" height="1"&gt;</description></item><item><title> Kathy Kam Designing Time Zone conversions | patio set</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#9771828</link><pubDate>Thu, 18 Jun 2009 05:23:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9771828</guid><dc:creator> Kathy Kam Designing Time Zone conversions | patio set</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://patiosetsite.info/story.php?id=853"&gt;http://patiosetsite.info/story.php?id=853&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9771828" width="1" height="1"&gt;</description></item><item><title>pacific standard timezone conversion</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#8590174</link><pubDate>Tue, 10 Jun 2008 20:07:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8590174</guid><dc:creator>pacific standard timezone conversion</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://krista.bigpicturesite.com/pacificstandardtimezoneconversion.html"&gt;http://krista.bigpicturesite.com/pacificstandardtimezoneconversion.html&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8590174" width="1" height="1"&gt;</description></item><item><title>re: Designing &amp;quot;Time Zone conversions&amp;quot;</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#756457</link><pubDate>Fri, 15 Sep 2006 23:10:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:756457</guid><dc:creator>Steve</dc:creator><description>I have been struggling with this issue for some time. &amp;nbsp;I have a scheduling utility that takes a TZ specific DateTime, and I need to convert that to local system time to know when to run.&lt;br&gt;&lt;br&gt;Also, it is possible to overload, inherit, partial, or by any means derive from the DateTime structure? &amp;nbsp;Then I could add some of the features I need.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=756457" width="1" height="1"&gt;</description></item><item><title>Is modifying System.DateTime reasonable for a Time Zone/Offset aware DateTime object? </title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#740761</link><pubDate>Tue, 05 Sep 2006 10:58:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:740761</guid><dc:creator>Kathy Kam</dc:creator><description>So, in my previous &amp;amp;quot;Designing Time Zone Conversion&amp;amp;quot; post, a few readers asked whether we can update System.DateTime...&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=740761" width="1" height="1"&gt;</description></item><item><title>re: Designing &amp;quot;Time Zone conversions&amp;quot;</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#691456</link><pubDate>Tue, 08 Aug 2006 00:58:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:691456</guid><dc:creator>John Glassman</dc:creator><description>In Jonathan Allen &amp;nbsp;reply above, he brings up the issue of an implicit adjustment for DST to a dateAdd calculation. While I would find optional argument to support this in an interface very useful, I would caution against having any such behavior a default. Comparisons to the time line against fixed units of time are fundamental to many business rules and SLA's (service level agreements) and critical to correct accounting and billing practices for countless purposes. Such a behavior may certainly make it simpler to produce checks to see if an end time properly falls withing a set turn around time as time stamps could be directly compared with the result of the DateAdd, DateDiff, or whatever interval a range is based on. However, the use of these functions are fundemtal to existing calculation that may also then use addition inputs to adjust for DLS or Time Zone differences, especily if UTC time is not availble in the source data. If I add 5 hours to a datetime value, I should always expect it to show me a result time that is exactly 5 hour ahead, regardless of the calendar date and DST settings. But adding an ApplyDST boolean, and a zone id as an option would really be keen for a lot of applications and would simplify the production of such code. Any chance for getting these sort of time zone transforms built into SQLserver and SSIS?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=691456" width="1" height="1"&gt;</description></item><item><title>re: Designing &amp;quot;Time Zone conversions&amp;quot;</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#671973</link><pubDate>Thu, 20 Jul 2006 02:20:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:671973</guid><dc:creator>Michael Giagnocavo</dc:creator><description>&lt;br&gt;Hi Kathy, thanks for writing back! I love discussions too.&lt;br&gt;&lt;br&gt;&amp;quot;&lt;br&gt;&amp;gt;&amp;gt;Why is storing &amp;quot;Pacific Time&amp;quot; not sufficient?&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;Storing just &amp;quot;PST&amp;quot; is insufficient, because &amp;quot;PST&amp;quot; is simply an ID for you to look up the actual time zone rules. Different &lt;br&gt;&lt;br&gt;&amp;gt;machine can have different DB. So your actual time will be different if you only store the ID. &lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;E.g. &lt;br&gt;&amp;gt;Machine A has the following PST rule: &lt;br&gt;&amp;gt;Offset = -8 hours &lt;br&gt;&amp;gt; &amp;lt;snip&amp;gt;&lt;br&gt;&amp;gt;Then.. March 31st 6:00pm (PST) will represent different time for Machine A and Machine B. Conversions between UTC and other &lt;br&gt;&lt;br&gt;&amp;gt;time zones will result in different values. &lt;br&gt;&amp;quot;&lt;br&gt;&lt;br&gt;**&lt;br&gt;But that's what we have now. If someone doesn't install a time zone update, then if I tell them &amp;quot;hey, meet you at 5PM Pacific &lt;br&gt;&lt;br&gt;Time&amp;quot;, they'll show up at a different UTC time than I would expect. I don't think it's unreasonable to have to have people to &lt;br&gt;&lt;br&gt;install updates to get correct time display. As you pointed out, the rules change year to year (sometimes as fast as a &lt;br&gt;&lt;br&gt;month), so the database will be large, and we can't be attaching that every time.&lt;br&gt;**&lt;br&gt;&lt;br&gt;&amp;quot;&lt;br&gt;&amp;gt;&amp;quot;Physical location has nothing to do with which timezone you choose,&amp;quot; &lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;Physical location has everything to do with which time zone you choose. Our time zones are being differentiated by location! &lt;br&gt;&amp;quot;&lt;br&gt;**&lt;br&gt;OK, I'll admit I chose some very poor wording. I meant to say that physical location alone cannot determine time zone. &lt;br&gt;&lt;br&gt;Someone could be travelling, be working with other users and hence have their time zone set differently, etc. On all our &lt;br&gt;&lt;br&gt;server software, we set the clocks to UTC, and store all dates in UTC (so we never get burned by DST). &lt;br&gt;&lt;br&gt;I wouldn't be surprised if, at some point in the future, some political/religious group declares one time zone, and another &lt;br&gt;&lt;br&gt;declares another, for the same latitude and longitude! Indeed, seeing how countries are prone to dispute territories, I'd be &lt;br&gt;&lt;br&gt;pretty certain this will arise (if it has not already). My point is that even if we did have an XYZ associated with a date &lt;br&gt;&lt;br&gt;time, it would not give us enough information.&lt;br&gt;**&lt;br&gt;&lt;br&gt;&amp;quot;&lt;br&gt;&amp;gt;People doesn't care about the time zone they are selecting. They only care about the time of day it is in a particular &lt;br&gt;&lt;br&gt;&amp;gt;location. When I call home to Hong Kong, I don't care what time zone they are in. All I care about is that I don't wake my &lt;br&gt;&lt;br&gt;&amp;gt;parents up at 3am in the morning. Users want a easy way to deal with time zone.Time zone gives people headache. Even the &lt;br&gt;&lt;br&gt;&amp;gt;best of us! :) The challenge is in how much we encapsulate and how much flexibility we allow our users to have. Do our &lt;br&gt;&lt;br&gt;&amp;gt;developers need to know about the actual rule changes? How much flexibility do we give them? Since we're the BCL, and the &lt;br&gt;&lt;br&gt;&amp;gt;&amp;quot;B&amp;quot; really stands for &amp;quot;broad variety of users&amp;quot;. This is the design challenge I am trying to highlight in this post.&lt;br&gt;&amp;quot;&lt;br&gt;&lt;br&gt;**&lt;br&gt;I know the responsibility of being on the BCL must be awesome, and I envy you guys :). I think the main difference in &lt;br&gt;&lt;br&gt;viewpoints is what you've highlighted here. If you view it from the point of &amp;quot;a person just wants to have their appointments &lt;br&gt;&lt;br&gt;work&amp;quot;, then you can take a lot of freedom. But, each app has to deal with this stuff its own way. For a simple appointment in &lt;br&gt;&lt;br&gt;Outlook (i.e., just a reminder to myself), it's obviously really easy. Store your information in the local time and the OS &lt;br&gt;&lt;br&gt;takes care of you.&lt;br&gt;&lt;br&gt;However, how does an app differentiate:&lt;br&gt;	- Tied to another time zone&lt;br&gt;	- Tied to a specific offset&lt;br&gt;	- Tied to the local system time (I want to wake up 9AM. If I move around the world, I want it to be 9AM.)&lt;br&gt;&lt;br&gt;You can replicate these things in Outlook. If you are scheduling with n people, some in DST-enabled time zones, some not, and &lt;br&gt;&lt;br&gt;someone gets an update -- what did they actually agree on as the time? I ran into this a year ago. I lived in a non-DST zone &lt;br&gt;&lt;br&gt;(UTC-6), and had agreed to meet at 11AM &amp;quot;MDT&amp;quot; (UTC-6). Come fall, what time were we supposed to meet at? &lt;br&gt;&lt;br&gt;In the Utah example -- how does my time change from &amp;quot;Mountain Time&amp;quot; to &amp;quot;Utah Time&amp;quot;? If I manually select it, am I saying &lt;br&gt;&lt;br&gt;&amp;quot;hey, I moved from Colorado to Utah&amp;quot;? If it auto updates, how does it know that chaning the time is correct? &lt;br&gt;&lt;br&gt;I love it when Microsoft solves a hard problem for us (that's why MS is so big, I think?). That makes devs love MS. But, we &lt;br&gt;&lt;br&gt;should have to enroll in this functionality explicitly (even if it's only a few lines of code, or heaven forbid, a wizard &lt;br&gt;&lt;br&gt;;)), rather than letting it happen &amp;quot;automagically&amp;quot;. A good example is the whole SOAP DateTime problem, where, IIRC, the &lt;br&gt;&lt;br&gt;serialization always embedded a UTC offset, creating a lot of problems (I was hit by it a long time ago), since the time zone &lt;br&gt;&lt;br&gt;might have been agreed on explicitly by the other side.&lt;br&gt;&lt;br&gt;I'd suggest that the APIs easily allow us to detect when a time zone was shifted, and then manipulate them. The application &lt;br&gt;&lt;br&gt;then needs to determine if/how it wants to update data, and what that entails in its context. For instance, if my &lt;br&gt;&lt;br&gt;appointments just shifted because Political Leader decided that if we offset by two hours for DST, maybe I (the user) will &lt;br&gt;&lt;br&gt;say, no, this appointment is a picnic, so I need it to stay relative to the sun. Or, perhaps, the application needs to send &lt;br&gt;&lt;br&gt;out sync messages or who knows what. &lt;br&gt;&lt;br&gt;A thing I love about the .NET and the BCL is that we can do things many ways. And a lot of value of the BCL is making &lt;br&gt;&lt;br&gt;classes/methods that wrap up otherwise available functionality. File.ReadAllLines is a great example of this. So, in the &lt;br&gt;&lt;br&gt;concept of dealign with changing time zones, perhaps we should be able to store a DateTime with a few extra bits of data so &lt;br&gt;&lt;br&gt;that the application can indicate if there is a time zone, and if so, what meaning does that have in light of changing zones &lt;br&gt;&lt;br&gt;(i.e., Mountain -&amp;gt; Utah), updates (new DST rules), and so on. Then, things can &amp;quot;magically&amp;quot; be converted for the app, and the &lt;br&gt;&lt;br&gt;dev has just delivered a lot more value without a whole lot of deep thought about TZs - they just set a few enums or clicked &lt;br&gt;&lt;br&gt;something in a wizard that did it for them. Meanwhile, developers who know what they are doing can work with things &lt;br&gt;&lt;br&gt;themselves.&lt;br&gt;&lt;br&gt;**&lt;br&gt;&lt;br&gt;&amp;quot;&lt;br&gt;&amp;gt;&amp;gt;Just because someone makes up a new time zone for Utah does not mean that everyone immediately and automatically has to &lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;adopt it.&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;If the government changes the time zone on Utah, EVERYONE will adopt and use it. Yes, if some random person does this, no &lt;br&gt;&lt;br&gt;&amp;gt;one would care, but if our government changes it. It will make a difference. We know our governments changes time zone, &lt;br&gt;&lt;br&gt;&amp;gt;Australia is doing it, USA is doing it ...etc. &lt;br&gt;&amp;quot;&lt;br&gt;&lt;br&gt;Sure, but then one county in Utah might decide against it for whatever reason, with half of the people there going along and &lt;br&gt;&lt;br&gt;half not. This year, Guatemala arbitrarily decided to implement DST (they had been fixed on UTC-6). So, within a month or &lt;br&gt;&lt;br&gt;two, they moved from UTC-6 to UTC-5. Many people living in certain villages simply did not respect this change for many &lt;br&gt;&lt;br&gt;reasons (some called it &amp;quot;devil time&amp;quot;). Then again, those people don't typically use Windows or .NET, so perhaps it's &lt;br&gt;&lt;br&gt;irrelevant to the BCL team. But something interesting is that, AFAIK, there is no OS patch for this one-year DST for &lt;br&gt;&lt;br&gt;Guatemala, or the other countries that soon sorta followed suit (they picked different days to revert) -- at least, I haven't &lt;br&gt;&lt;br&gt;seen anything on Windows update about it, and my time zone list looks the same. Not sure exactly what this means to BCL &lt;br&gt;&lt;br&gt;either. If it's not in the timezone DB, then it doesn't exist?&lt;br&gt;&lt;br&gt;Anyways, my bottom line is, please please please ensure that by default, devs must specify what their intent is. If there is &lt;br&gt;&lt;br&gt;some awesome thing that BCL comes up with that just magically deals with time zones, then make us explicitly opt-in to that. &lt;br&gt;&lt;br&gt;Also, I just saw the new comments -- the &amp;quot;DateTimeZone&amp;quot; class -- that would just be like Time Zone Info, right? It's not a different class to store datetime in (that'd be confusing and difficult)?&lt;br&gt;&lt;br&gt;Thanks a lot!&lt;br&gt;-Michael&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=671973" width="1" height="1"&gt;</description></item><item><title>re: Designing &amp;quot;Time Zone conversions&amp;quot;</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#671908</link><pubDate>Thu, 20 Jul 2006 01:21:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:671908</guid><dc:creator>Oren Novotny</dc:creator><description>Sorry, I was unclear in my last comment -- extending the existing DateTime class is preferable to creating a new class since DateTime is already in wide use and it would be a huge effort to replace one type with the other everywhere. &amp;nbsp;&lt;br&gt;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=671908" width="1" height="1"&gt;</description></item><item><title>re: Designing &amp;quot;Time Zone conversions&amp;quot;</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#671906</link><pubDate>Thu, 20 Jul 2006 01:17:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:671906</guid><dc:creator>Oren Novotny</dc:creator><description>One thing that would be very helpful would be if you could release a shared-source implementation of these new DateTimeZone classes so that we can start using them sooner rather than later.&lt;br&gt;&lt;br&gt;Many of us are dealing with these issues regularly and we'd rather not have to wait a long time until a BCL 3 is officially released. &amp;nbsp;&lt;br&gt;&lt;br&gt;Another thing -- if you're going to create a new DateTimeZone class rather than extend the existing DateTime (which would be preferable considering how many places DateTime is used), the new DateTimeZone class should have implicit conversion operators for DateTime. &amp;nbsp;That would enable a more seamless migration from one type to the other. &amp;nbsp;Since DateTime really stores its value as ticks from some constant UTC time, it should be possible to convert seamlessly.&lt;br&gt;&lt;br&gt;As far as some of your comments regarding where to store time zone rules, I think that it's a fair trade-off to rely on the local system having an up-to-date conversion table. &amp;nbsp;That way you wouldn't have to store the rules on the type thereby making it incredibly huge. &lt;br&gt;&lt;br&gt;In a majority of the systems that need time zone conversion it's because we're exchanging data with a remote system. &amp;nbsp;Almost by definition that means both systems are on a network and that means they're able to get updates. &amp;nbsp;&lt;br&gt;&lt;br&gt;--Oren&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=671906" width="1" height="1"&gt;</description></item><item><title>re: Designing &amp;amp;amp;quot;Time Zone conversions&amp;amp;amp;quot;</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/07/13/665019.aspx#670176</link><pubDate>Wed, 19 Jul 2006 00:20:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:670176</guid><dc:creator>KathyKam [MSFT]</dc:creator><description>&lt;P&gt;Hi Michael, &lt;/P&gt;
&lt;P&gt;I love discussions! Thanks for the feedback!&amp;nbsp;Let me answer your question, before I dive in..&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Why is storing "Pacific Time" not sufficient?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Storing just "PST" is insufficient, because "PST" is simply an ID for you to look up the actual time zone rules. Different machine can have different DB. So your actual time will be different if you only store the ID. &lt;BR&gt;&lt;BR&gt;E.g. &lt;BR&gt;Machine A has the following PST rule: &lt;BR&gt;Offset = -8 hours &lt;BR&gt;Daylight saving offset = -7 hours &lt;BR&gt;Transition Start Date: 1st Sunday of April &lt;BR&gt;Transition End Date: Last Sunday of October &lt;BR&gt;&lt;BR&gt;Machine B has the following PST rule: &lt;BR&gt;Offset = -8 hours &lt;BR&gt;Daylight saving offset = -7 hours &lt;BR&gt;Transition Start Date: 2nd Sunday of March &lt;BR&gt;Transition End Date: 1st Sunday of Nov &lt;BR&gt;&lt;BR&gt;Then.. March 31st 6:00pm (PST) will represent different time for Machine A and Machine B. Conversions between UTC and other time zones will result in different values. &lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"Physical location has nothing to do with which timezone you choose," &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Physical location has everything to do with which time zone you choose. Our time zones are being differentiated by location! People doesn't care about the time zone they are selecting. They only care about the time of day it is in a particular location. When I call home to Hong Kong, I don't care what time zone they are in. All I care about is that I don't wake my parents up at 3am in the morning. Users want a easy way to deal with time zone.Time zone gives people &lt;A href="http://blogs.msdn.com/oldnewthing/archive/2003/10/24/55413.aspx"&gt;headache&lt;/A&gt;. Even the best of us! :) The challenge is in how much we encapsulate and how much flexibility we allow our users to have. Do our developers need to know about the actual rule changes? How much flexibility do we give them? Since we're the BCL, and the "B" really stands for "broad variety of users". This is the design challenge I am trying to highlight in this post.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Just because someone makes up a new time zone for Utah does not mean that everyone immediately and automatically has to adopt it.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;If the government changes the time zone on Utah, EVERYONE will adopt and use it. Yes, if some random person does this, no one would care, but if our government changes it. It will make a difference. We know our governments changes time zone, Australia is doing it, USA is doing it ...etc. &lt;BR&gt;&lt;BR&gt;What do you think?&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Kathy&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=670176" width="1" height="1"&gt;</description></item></channel></rss>