<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Silverlight Server / Client - Different time zones</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Silverlight Server / Client - Different time zones</description>
  <pubDate>Wed, 29 Jul 2026 16:07:38 -700</pubDate>
  <lastBuildDate>Thu, 17 Feb 2011 17:16:13 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=2513</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Silverlight Server / Client - Different time zones : Hi ajhops;I did some testing in...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9978#9978</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2513<br /><strong>Posted:</strong> 17-Feb-2011 at 5:16pm<br /><br />Hi ajhops;<div><br></div><div>I did some testing in regards to your above questions.</div><div><br></div><div>1. "<span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">The ReportDate field appears to be auto generated with a DateTime.Now.Date&nbsp;</span></div><div><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  (midnight of today on the client *LOCAL* time). <b>Can anybody verify that this is the designed behavior?"</b></span></div><div><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><b><br></b></span></div><div><font ="Apple-style-span" face="c&#111;nsolas"><span ="Apple-style-span" style="white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><b><span ="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; white-space: normal; -webkit-border-horiz&#111;ntal-spacing: 0px; -webkit-border-vertical-spacing: 0px; ">I believe this happens if you don't set your ReportDate field as nullable. In my test, my DateTime field is nullable and upon new entity creation, my DateTime field is set to null. I can then set it to any DateTime object I want.</span></b></span></font></div><div><font ="Apple-style-span" face="c&#111;nsolas"><span ="Apple-style-span" style="white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><b><span ="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; white-space: normal; -webkit-border-horiz&#111;ntal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><br></span></b></span></font></div><div><font ="Apple-style-span" face="c&#111;nsolas"><span ="Apple-style-span" style="white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><b><span ="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; white-space: normal; -webkit-border-horiz&#111;ntal-spacing: 0px; -webkit-border-vertical-spacing: 0px; ">2.&nbsp;</span></b></span></font><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">A few lines later I try setting ReportDate to a different DateTime&nbsp;</span><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">(midnight of today on the client *UTC*)&nbsp;</span></div><div><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  time, </span><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">this set does nothing. </span><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><span>PropertyMetadata</span>.ReportDate.SetValue(<span style="color: blue; ">this</span>,&nbsp;<span style="color: blue; ">value</span>); appears to determine that the</span></div><div><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  setter is trying to&nbsp;</span><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">set the value to what it already is and ignores it (even though datetimekind are&nbsp;</span></div><div><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  different). </span><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><b>Can anybody verify this?"</b></span></div><div><span ="Apple-style-span" style="font-family: c&#111;nsolas; white-space: pre; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><b><br></b></span></div><div>I did the same test and encountered the same behavior. As you have verified, it looks like when comparing 2 different DateTime objects, .NET ignores the DateTimeKind and only compares the date and time. In this case, since the midnight part of the DateTime objects are the same, the set does nothing.</div><div><br></div><div>3. "<span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">I found the problem.</span></div><div style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">&nbsp;&nbsp;</div><div style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "> <span style="color: rgb43, 145, 175; font-family: c&#111;nsolas; white-space: pre; ">   DateTime</span><font ="Apple-style-span" color="#2B91AF" face="c&#111;nsolas"><span ="Apple-style-span" style="white-space: pre;">.Today == </span></font><span ="apple-style-span"="" style="color: rgb43, 145, 175; font-family: c&#111;nsolas; white-space: pre; "><span style="color: rgb43, 145, 175; ">DateTime</span>.SpecifyKind(<span style="color: rgb43, 145, 175; ">DateTime</span>.Today,&nbsp;System.DateTimeKind.Utc) </span><span ="Apple-style-span" style="color: rgb43, 145, 175; font-family: c&#111;nsolas; white-space: pre; ">evaluates to True.&nbsp;</span></div><div style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><span ="Apple-style-span" style="color: rgb43, 145, 175; font-family: c&#111;nsolas; white-space: pre; ">   I did not expect this.</span></div><div style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><span ="Apple-style-span" style="color: rgb43, 145, 175; font-family: c&#111;nsolas; white-space: pre; "><br></span></div><div>Again, it seems that the DateTime object comparison (==) operator ignores the DateTimeKind part of the DateTime object. The following tests below seem to confirm it.</div><div><br></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp;DateTime utcDt = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc);</div><div>&nbsp;&nbsp; &nbsp; &nbsp;DateTime localDt = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Local);</div><div>&nbsp;&nbsp; &nbsp; &nbsp;DateTime unspecDt = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Unspecified);</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;bool isTrue1 = (DateTime.Today == utcDt);<span ="Apple-tab-span" style="white-space:pre">		</span>//true</div><div>&nbsp;&nbsp; &nbsp; &nbsp;bool isTrue2 = (DateTime.Today == localDt);<span ="Apple-tab-span" style="white-space:pre">		</span>//true</div><div>&nbsp;&nbsp; &nbsp; &nbsp;bool isTrue3 = (DateTime.Today == unspecDt);<span ="Apple-tab-span" style="white-space:pre">		</span>//true</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;bool isTrue4 = (DateTime.Today.Kind == utcDt.Kind);<span ="Apple-tab-span" style="white-space:pre">		</span>//false</div><div>&nbsp;&nbsp; &nbsp; &nbsp;bool isTrue5 = (DateTime.Today.Kind == localDt.Kind);<span ="Apple-tab-span" style="white-space:pre">		</span>//true</div><div>&nbsp;&nbsp; &nbsp; &nbsp;bool isTrue6 = (DateTime.Today.Kind == unspecDt.Kind);<span ="Apple-tab-span" style="white-space:pre">		</span>//false</div></div>]]>
   </description>
   <pubDate>Thu, 17 Feb 2011 17:16:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9978#9978</guid>
  </item> 
  <item>
   <title>Silverlight Server / Client - Different time zones : I found the problem.DateTime.Today...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9975#9975</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=906" rel="nofollow">ajhops</a><br /><strong>Subject:</strong> 2513<br /><strong>Posted:</strong> 17-Feb-2011 at 6:36am<br /><br />I found the problem.<div><br></div><div><pre style="font-family: c&#111;nsolas"><font ="Apple-style-span" color="#2B91AF"><pre style="font-family: c&#111;nsolas"><span style="color: #2b91af">DateTime</span>.Today == <span ="Apple-style-span" style="color: rgb0, 0, 0; "><span style="color: #2b91af">DateTime</span>.SpecifyKind(<span style="color: #2b91af">DateTime</span>.Today,&nbsp;System.DateTimeKind.Utc)</span></pre><pre style="font-family: c&#111;nsolas"><span ="Apple-style-span" style="color: rgb0, 0, 0; ">evaluates to True. I did not expect this.</span></pre></font><pre style="font-family: c&#111;nsolas"><br></pre></pre></div>]]>
   </description>
   <pubDate>Thu, 17 Feb 2011 06:36:05 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9975#9975</guid>
  </item> 
  <item>
   <title>Silverlight Server / Client - Different time zones : Sorry for the poor wording. I...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9974#9974</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=906" rel="nofollow">ajhops</a><br /><strong>Subject:</strong> 2513<br /><strong>Posted:</strong> 17-Feb-2011 at 5:49am<br /><br />Sorry for the poor wording. I struggled to describe the problem without going into a paragraph long description of our business requirements. Basically, this particular field is always a midnight DateTime. It needs to show midnight in the database, server, client even when all are in different time zones. The user chooses a date on a calendar control to set this field.<div><br></div><div>After poking around I have some questions that should lead me to an answer.&nbsp;</div><div><br></div><div>Here is the definition of the property:</div><div><br></div><div><pre style="font-family: c&#111;nsolas"><span style="color: blue">#region</span>&nbsp;ReportDate&nbsp;property<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: gray">///</span><span style="color: green">&nbsp;</span><span style="color: gray">&lt;summary&gt;</span><span style="color: green">Gets&nbsp;or&nbsp;sets&nbsp;the&nbsp;ReportDate.&nbsp;</span><span style="color: gray">&lt;/summary&gt;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: #2b91af">Bindable</span>(<span style="color: blue">true</span>,&nbsp;<span style="color: #2b91af">BindingDirection</span>.TwoWay)&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: #2b91af">Editable</span>(<span style="color: blue">true</span>)&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: #2b91af">Display</span>(Name=<span style="color: #a31515">"ReportDate"</span>,&nbsp;AutoGenerateField=<span style="color: blue">true</span>)&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&#091;IbVal.<span style="color: #2b91af">RequiredValueVerifier</span>(&nbsp;ErrorMessageResourceName=<span style="color: #a31515">"IADCHeader_ReportDate"</span>)&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: #2b91af">DataMember</span>&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">public</span>&nbsp;System.<span style="color: #2b91af">DateTime</span>&nbsp;ReportDate&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">get</span>&nbsp;{&nbsp;<span style="color: blue">return</span>&nbsp;<span style="color: #2b91af">PropertyMetadata</span>.ReportDate.GetValue(<span style="color: blue">this</span>);&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">set</span>&nbsp;{&nbsp;<span style="color: #2b91af">PropertyMetadata</span>.ReportDate.SetValue(<span style="color: blue">this</span>,&nbsp;<span style="color: blue">value</span>);&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><span style="color: blue">#endregion</span>&nbsp;ReportDate&nbsp;property</pre><pre style="font-family: c&#111;nsolas">We construct our entity using Manager.CreateEntity&lt;T&gt;</pre><pre style="font-family: c&#111;nsolas">The ReportDate field appears to be auto generated with a DateTime.Now.Date (midnight of today on the client *LOCAL* time). <b>Can anybody verify that this is the designed behavior?</b></pre><pre style="font-family: c&#111;nsolas">A few lines later I try setting ReportDate to a different DateTime (midnight of today on the client *UTC*) time, this set does nothing. <span style="color: rgb43, 145, 175; ">PropertyMetadata</span>.ReportDate.SetValue(<span style="color: blue; ">this</span>,&nbsp;<span style="color: blue; ">value</span>); appears to determine that the setter is trying to set the value to what it already is and ignores it (even though datetimekind are different). <b>Can anybody verify this?</b></pre><pre style="font-family: c&#111;nsolas"><b><br></b></pre><pre style="font-family: c&#111;nsolas">I truly appreciate any light the ideablade folks or community can shed on how EF/Devforce handle datetimes and DateTimeKinds. </pre><pre style="font-family: c&#111;nsolas"><br></pre><pre style="font-family: c&#111;nsolas"><br></pre><pre style="font-family: c&#111;nsolas"><br></pre></div>]]>
   </description>
   <pubDate>Thu, 17 Feb 2011 05:49:37 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9974#9974</guid>
  </item> 
  <item>
   <title>Silverlight Server / Client - Different time zones : Hi ajhops;DevForce does not do...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9972#9972</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2513<br /><strong>Posted:</strong> 16-Feb-2011 at 3:30pm<br /><br />Hi ajhops;<div><br></div><div>DevForce does not do anything special with the serialization/deserialization process.</div><div><br></div><div>I don't quite follow this statement, "<span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">The weird part is that by "occasionally" I mean only when the field is being set to midnight of today - UTC."</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">In the previous statement, you said "</span><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">On the client, when setting the property we always set it to midnight UTC".</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">It sounds like you don't always set the property to midnight UTC? Could you clarify?</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">Researching more, I found that DateTime object does get stored with different values if the client and server are on different time zones. The recommended practice to deal with this scenario is to use DateTimeKind.Utc and apply a time zone conversion as required.</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">I came across this article that might be useful for you.</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">Coding Best Practices Using DateTime in the .NET Framework.</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><a href="http://msdn.microsoft.com/en-us/library/ms973825.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms973825.aspx</a></span></div><div><br></div><div>Hope this helps.</div>]]>
   </description>
   <pubDate>Wed, 16 Feb 2011 15:30:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9972#9972</guid>
  </item> 
  <item>
   <title>Silverlight Server / Client - Different time zones : I don&amp;#039;t know how to begin...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9971#9971</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=906" rel="nofollow">ajhops</a><br /><strong>Subject:</strong> 2513<br /><strong>Posted:</strong> 16-Feb-2011 at 1:10pm<br /><br />I don't know how to begin debugging this.<div><br></div><div>An entity has a date time property. Client is in time zone UTC+13 hours. Server is in time zone UTC - 6 hours.</div><div><br></div><div>On the client, when setting the property we always set it to midnight UTC (the field is meant to designate a date only).</div><div><br></div><div>Most of the time the field is saved server side with a 00:00:00 time component. Occasionally it is set with a 05:00:00 time component. The weird part is that by "occasionally" I mean only when the field is being set to midnight of today - UTC.</div><div><br></div><div>Can anybody help me find definitive facts about how datetime objects are serialized/deserialized between client and server (does devforce do anything special??).</div><div><br></div><div>Much Appreciated,</div><div>-Adam&nbsp;</div>]]>
   </description>
   <pubDate>Wed, 16 Feb 2011 13:10:57 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2513&amp;PID=9971#9971</guid>
  </item> 
 </channel>
</rss>