<?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>DansNetwork.com &#187; date</title>
	<atom:link href="http://dansnetwork.com/tag/date/feed/" rel="self" type="application/rss+xml" />
	<link>http://dansnetwork.com</link>
	<description>Web Design, Javascript, CSS, and More...</description>
	<lastBuildDate>Wed, 19 May 2010 20:02:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JavaScript ISO8601/RFC3339 Date Parser</title>
		<link>http://dansnetwork.com/2008/11/01/javascript-iso8601rfc3339-date-parser/</link>
		<comments>http://dansnetwork.com/2008/11/01/javascript-iso8601rfc3339-date-parser/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 03:26:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[iso8601]]></category>
		<category><![CDATA[javascript]]></category>
		<guid isPermaLink="false">http://blog.dansnetwork.com/2008/11/01/javascript-iso8601rfc3339-date-parser/</guid>
		<description><![CDATA[Updated (bug fix): 2-11-09
In need of a JavaScript function that would parse an ISO8601 compliant date, I came across an attempt (http://delete.me.uk/2005/03/iso8601.html) and rewrote it (because I&#8217;m all about reinventing the wheel). My function extends the Date object and allows you to pass in an ISO8601 date (2008-11-01T20:39:57.78-06:00). The function will then return the Date. [...]]]></description>
			<content:encoded><![CDATA[<p>Updated (bug fix): 2-11-09</p>
<p>In need of a JavaScript function that would parse an ISO8601 compliant date, I came across an attempt (<a href="http://delete.me.uk/2005/03/iso8601.html" title="iso8601">http://delete.me.uk/2005/03/iso8601.html</a>) and rewrote it (because I&#8217;m all about reinventing the wheel). My function extends the Date object and allows you to pass in an ISO8601 date (<strong>2008-11-01T20:39:57.78-06:00</strong>). The function will then return the Date. In the date string argument the dashes and colons are optional. The decimal point for milliseconds is mandatory (although specifying milliseconds isn&#8217;t). If a timezone offset is specified, the &#8216;+&#8217; or &#8216;-&#8217; sign must be included. This function should also work with iCalendar(RFC2445) formatted dates. If a the date string doesn&#8217;t match the format, there will be a final attempt to parse it with the built in Date.parse() method.</p>
<p>Code:</p>
<pre class="brush: jscript;">
Date.prototype.setISO8601 = function(dString){
var regexp = /(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+-])(\d\d)(:)?(\d\d))/;
if (dString.toString().match(new RegExp(regexp))) {
var d = dString.match(new RegExp(regexp));
var offset = 0;
this.setUTCDate(1);
this.setUTCFullYear(parseInt(d[1],10));
this.setUTCMonth(parseInt(d[3],10) - 1);
this.setUTCDate(parseInt(d[5],10));
this.setUTCHours(parseInt(d[7],10));
this.setUTCMinutes(parseInt(d[9],10));
this.setUTCSeconds(parseInt(d[11],10));
if (d[12])
this.setUTCMilliseconds(parseFloat(d[12]) * 1000);
else
this.setUTCMilliseconds(0);
if (d[13] != 'Z') {
offset = (d[15] * 60) + parseInt(d[17],10);
offset *= ((d[14] == '-') ? -1 : 1);
this.setTime(this.getTime() - offset * 60 * 1000);
}
}
else {
this.setTime(Date.parse(dString));
}
return this;
};
</pre>
<p>Usage:</p>
<pre class="brush: jscript;">
var today = new Date();
today.setISO8601('2008-12-19T16:39:57.67Z');
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dansnetwork.com/2008/11/01/javascript-iso8601rfc3339-date-parser/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
