<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hourahine.net &#187; Code Snippets</title>
	<atom:link href="http://www.hourahine.net/index.php/category/code-snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hourahine.net</link>
	<description>The digital lifestream for Mike Hourahine</description>
	<lastBuildDate>Mon, 26 Apr 2010 13:29:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Times, Timezones and Daylight Savings</title>
		<link>http://www.hourahine.net/index.php/2005/08/times-timezones-and-daylight-savings/</link>
		<comments>http://www.hourahine.net/index.php/2005/08/times-timezones-and-daylight-savings/#comments</comments>
		<pubDate>Wed, 31 Aug 2005 22:53:50 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.hourahine.net/wp/?p=9</guid>
		<description><![CDATA[Oh man&#8230; I just made it through a bit of a timezone thing so I thought I&#8217;d record it here for propersity (and so I never need to deal with it again). Background info: Here is some information regarding Date and Time Format standards from W3C: http://www.w3.org/TR/NOTE-datetime Here is another link regarding Best Practices with [...]]]></description>
			<content:encoded><![CDATA[<p>Oh man&#8230; I just made it through a bit of a timezone thing so I thought I&#8217;d record it here for propersity (and so I never need to deal with it again).</p>
<p><strong>Background info:</strong></p>
<p>Here is some information regarding Date and Time Format standards from W3C:  <a href="http://www.w3.org/TR/NOTE-datetime">http://www.w3.org/TR/NOTE-datetime</a></p>
<p>Here is another link regarding <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/datetimecode.asp">Best Practices with Dates and Times in .NET</a></p>
<p>And finally, here&#8217;s a link to the <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtimezoneclasstopic.asp">MSDN reference on the Timezone class</a></p>
<p><strong>My problem: </strong>Basically, I&#8217;m building an web application to import a bunch of events into an Exchange calendar via WEBDAV.  This method requires dates and times for events being in the following format:  yyyy-MM-ddTHH:mm:ss.fffZ</p>
<p>As specified by the W3C:  the &#8216;T&#8217; is a literal character that represents the start of the time section.  The &#8216;Z&#8217; however is a short form for the UTC timezone.  You can replace this with a timezone offset like &#8220;-04:00&#8243;.  So that makes &#8220;2005-07-20T10:30:00.000-04:00&#8243; a valid time format.</p>
<p><strong>Enter my horror:</strong>  The problem is that in areas that observe Daylight Savings time the offset will change depending on whether or not you&#8217;re within the daylight saving time frame.  This is compounded when adding future events because you to need to ensure it is the correct offset for the time when the event is going to occur.</p>
<p><strong>.NET to the rescue:</strong>  Luckily .NET has some classes for dealing with this.  The following code snippet will automatically format your date object in a recognized W3C format and will add the correct offset for your timezone.  It will also automatically adjust for Daylight Savings Time:</p>
<p><code><br />
'You must import the System namespace<br />
'startDateAdj, endDateAdj is declared and set to desired local time earlier<br />
Dim tz As TimeZone = TimeZone.CurrentTimeZone<br />
strStartDate = Format(startDateAdj, &quot;yyyy-MM-ddTHH:mm:ss.fff&quot;) &#038; tz.GetUtcOffset(startDateAdj).ToString<br />
strEndDate = Format(endDateAdj, &quot;yyyy-MM-ddTHH:mm:ss.fff&quot;) &#038; tz.GetUtcOffset(endDateAdj).ToString<br />
</code></p>
<p>Thank you .NET!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hourahine.net/index.php/2005/08/times-timezones-and-daylight-savings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Time Processes in .NET</title>
		<link>http://www.hourahine.net/index.php/2005/08/time-processes-in-net/</link>
		<comments>http://www.hourahine.net/index.php/2005/08/time-processes-in-net/#comments</comments>
		<pubDate>Fri, 26 Aug 2005 21:28:16 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.hourahine.net/wp/?p=8</guid>
		<description><![CDATA[Here&#8217;s some simple code to time a process in VB .NET. This particular example is for an ASP .NET app (hence the &#8220;Response.Write&#8221;: Dim ProcessStartTime As Date = Now 'CODE TO BE TIMED GOES HERE Dim RunLength As System.TimeSpan = Now.Subtract(ProcessStartTime) Dim Millisecs As Integer = RunLength.TotalMilliseconds Response.Write(&#34;Process Time: &#34; &#038; Millisecs &#038; &#34; ms&#34;)]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s some simple code to time a process in VB .NET.  This particular example is for an ASP .NET app (hence the &#8220;Response.Write&#8221;:</p>
<pre>
     Dim ProcessStartTime As Date = Now

     'CODE TO BE TIMED GOES HERE

     Dim RunLength As System.TimeSpan = Now.Subtract(ProcessStartTime)
     Dim Millisecs As Integer = RunLength.TotalMilliseconds
     Response.Write(&quot;Process Time: &quot; &#038; Millisecs &#038; &quot; ms&quot;)
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hourahine.net/index.php/2005/08/time-processes-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List Server Variables in ASP .NET</title>
		<link>http://www.hourahine.net/index.php/2005/07/list-server-variables-in-asp-net/</link>
		<comments>http://www.hourahine.net/index.php/2005/07/list-server-variables-in-asp-net/#comments</comments>
		<pubDate>Thu, 28 Jul 2005 21:15:04 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.hourahine.net/wp/?p=7</guid>
		<description><![CDATA[Want to see all the server variables in ASP .NET? Here&#8217;s some simple code to do it: 'Display server variables Dim strVar As String Response.Write("&#60;ul&#62;") For Each strVar In Request.ServerVariables Response.Write(&#34;&#60;li&#62;&#34; &#038; strVar &#038; &#34; = &#34; &#038; Request.ServerVariables(strVar) &#038; &#34;&#60;/li&#62;&#34;) Next Response.Write(&#34;&#60;/ul&#62;&#34;) It will output something similar to the following: ALL_HTTP = HTTP_CONNECTION:Keep-Alive HTTP_ACCEPT:image/gif, [...]]]></description>
			<content:encoded><![CDATA[<p>Want to see all the server variables in ASP .NET?  Here&#8217;s some simple code to do it:</p>
<p><code><br />
        'Display server variables<br />
        Dim strVar As String<br />
        Response.Write("&lt;ul&gt;")<br />
        For Each strVar In Request.ServerVariables<br />
            Response.Write(&quot;&lt;li&gt;&quot; &#038; strVar &#038; &quot; = &quot; &#038; Request.ServerVariables(strVar) &#038; &quot;&lt;/li&gt;&quot;)<br />
        Next<br />
        Response.Write(&quot;&lt;/ul&gt;&quot;)<br />
</code></p>
<p>It will output something similar to the following:</p>
<p><code>ALL_HTTP = HTTP_CONNECTION:Keep-Alive HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:en-us HTTP_COOKIE:ASP.NET_SessionId=1vykqy55smxyu1453uywdl55 HTTP_HOST:localhost HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)<br />
ALL_RAW = Connection: Keep-Alive Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Accept-Encoding: gzip, deflate Accept-Language: en-us Cookie: ASP.NET_SessionId=1vykqy55smxyu1453uywdl55 Host: localhost User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)<br />
APPL_MD_PATH = /LM/w3svc/1/root/WebApplication1<br />
APPL_PHYSICAL_PATH = c:\inetpub\wwwroot\WebApplication1\<br />
AUTH_TYPE =<br />
AUTH_USER =<br />
AUTH_PASSWORD =<br />
LOGON_USER =<br />
REMOTE_USER =<br />
CERT_COOKIE =<br />
CERT_FLAGS =<br />
CERT_ISSUER =<br />
CERT_KEYSIZE =<br />
CERT_SECRETKEYSIZE =<br />
CERT_SERIALNUMBER =<br />
CERT_SERVER_ISSUER =<br />
CERT_SERVER_SUBJECT =<br />
CERT_SUBJECT =<br />
CONTENT_LENGTH = 0<br />
CONTENT_TYPE =<br />
GATEWAY_INTERFACE = CGI/1.1<br />
HTTPS = off<br />
HTTPS_KEYSIZE =<br />
HTTPS_SECRETKEYSIZE =<br />
HTTPS_SERVER_ISSUER =<br />
HTTPS_SERVER_SUBJECT =<br />
INSTANCE_ID = 1<br />
INSTANCE_META_PATH = /LM/W3SVC/1<br />
LOCAL_ADDR = 127.0.0.1<br />
PATH_INFO = /WebApplication1/readfile.aspx<br />
PATH_TRANSLATED = c:\inetpub\wwwroot\WebApplication1\readfile.aspx<br />
QUERY_STRING =<br />
REMOTE_ADDR = 127.0.0.1<br />
REMOTE_HOST = 127.0.0.1<br />
REMOTE_PORT = 2210<br />
REQUEST_METHOD = GET<br />
SCRIPT_NAME = /WebApplication1/readfile.aspx<br />
SERVER_NAME = localhost<br />
SERVER_PORT = 80<br />
SERVER_PORT_SECURE = 0<br />
SERVER_PROTOCOL = HTTP/1.1<br />
SERVER_SOFTWARE = Microsoft-IIS/5.1<br />
URL = /WebApplication1/readfile.aspx<br />
HTTP_CONNECTION = Keep-Alive<br />
HTTP_ACCEPT = image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*<br />
HTTP_ACCEPT_ENCODING = gzip, deflate<br />
HTTP_ACCEPT_LANGUAGE = en-us<br />
HTTP_COOKIE = ASP.NET_SessionId=1vykqy55smxyu1453uywdl55<br />
HTTP_HOST = localhost<br />
HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hourahine.net/index.php/2005/07/list-server-variables-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
