<?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>Silveira Neto &#187; sorting</title>
	<atom:link href="http://silveiraneto.net/tag/sorting/feed/" rel="self" type="application/rss+xml" />
	<link>http://silveiraneto.net</link>
	<description>the world is a pixel</description>
	<lastBuildDate>Sun, 08 Jan 2012 05:17:57 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Easily Sortable Date and Time Representation</title>
		<link>http://silveiraneto.net/2010/01/20/easily-sortable-date-and-time-representation/</link>
		<comments>http://silveiraneto.net/2010/01/20/easily-sortable-date-and-time-representation/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 01:55:26 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[ISO 8601]]></category>
		<category><![CDATA[Jochen Voss]]></category>
		<category><![CDATA[Markus Kuhn]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[representation]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3130</guid>
		<description><![CDATA[I was looking for a date and time representation useful for registering stock quotes in a simple plain file. I found that the standard ISO 8601 is just the answer for this, it&#8217;s called &#8220;Data elements and interchange formats — Information interchange — Representation of dates and times&#8221;. Here is a example: 2010-01-20 22:14:38 There&#8217;s this [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a date and time representation useful for registering stock quotes in a simple plain file.</p>
<p>I found that the standard <a title="Wikipedia on ISO 8601" href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> is just the answer for this, it&#8217;s called &#8220;Data elements and interchange formats — Information interchange — Representation of dates and times&#8221;. Here is a example:</p>
<blockquote><p>2010-01-20 22:14:38</p></blockquote>
<p>There&#8217;s this good article from <a title="A summary of the international standard date and time notation" href="http://www.cl.cam.ac.uk/~mgk25/iso-time.html">Markus Kuhn, &#8220;A summary of the international standard date and time notation&#8221;</a>. <strong>This notation allow us to using simple lexicographical order the events.</strong></p>
<p>Some examples of how to do this in Python (thanks for the <a href="http://seehuhn.de/pages/pdate">Jochen Voss article &#8220;Date and Time Representation in Python&#8221;</a>) The first for displaying the current date and time:</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">time</span> <span style="color: #ff7700;font-weight:bold;">import</span> strftime
<span style="color: #ff7700;font-weight:bold;">print</span> strftime<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%Y-%m-%d %H:%M:%S&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># 2010-01-20 22:34:22</span></pre>
</div>
</div>
<p>Another possibility is using strftime from datetime object.</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">datetime</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
now = <span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> now.<span style="color: black;">strftime</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%Y-%m-%d %H:%M:%S&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># 2010-01-20 22:12:31</span></pre>
</div>
</div>
<p>Is that. Using this notation in the begging of each line is easy to sort them in any language or using the unix <a href="http://en.wikipedia.org/wiki/Sort_%28Unix%29">sort</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/01/20/easily-sortable-date-and-time-representation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

