<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>the rails loft - Comments for: Elegant (Non-Standard) Time Formatting</title>
    <link>http://railsloft.com/posts/elegant-non-standard-time-formatting/comments_rss</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>Comment on Elegant (Non-Standard) Time Formatting by Alex</title>
      <description>Alex says:&lt;br/&gt;That was the easy part.&lt;br/&gt;Now show us if you can extend that elegant 1-liner to PT00H00M00S!&lt;br/&gt;</description>
      <pubDate>Sun, 10 Feb 2008 06:52:48 -0500</pubDate>
      <link>http://railsloft.com/posts/elegant-non-standard-time-formatting</link>
      <guid>http://railsloft.com/posts/elegant-non-standard-time-formatting-comment-5</guid>
    </item>
    <item>
      <title>Comment on Elegant (Non-Standard) Time Formatting by Phil Matarese</title>
      <description>&lt;a href="http://agilepartners.com" rel="nofollow"&gt;Phil Matarese&lt;/a&gt; says:&lt;br/&gt;Alex, good point. I just played with this a bit, and there just isn't a nice way to deal with 3 parts using divmod.&lt;br/&gt;&lt;br/&gt;So, I wrote a quick method called divmodd that can split the number by multiple divisors:&lt;br/&gt;&lt;br/&gt;# this is excellent for time-formatting&lt;br/&gt;# and, it's a 1-liner without the definition stuff&lt;br/&gt;class Fixnum&lt;br/&gt; def divmodd(*nums)&lt;br/&gt;  nums.inject([self]){|a,n| a.shift.divmod(n) + a}&lt;br/&gt; end&lt;br/&gt;end&lt;br/&gt;&lt;br/&gt;#Now I can do it!&lt;br/&gt;format('PT%02dH%02dM%02dS', *d.divmodd(60, 60))</description>
      <pubDate>Mon, 11 Feb 2008 15:19:11 -0500</pubDate>
      <link>http://railsloft.com/posts/elegant-non-standard-time-formatting</link>
      <guid>http://railsloft.com/posts/elegant-non-standard-time-formatting-comment-7</guid>
    </item>
    <item>
      <title>Comment on Elegant (Non-Standard) Time Formatting by Phil Matarese</title>
      <description>&lt;a href="http://agilepartners.com" rel="nofollow"&gt;Phil Matarese&lt;/a&gt; says:&lt;br/&gt;While reading attachment_fu code, I just found out you can use % on a string as a call to format.  Like this:&lt;br/&gt;&lt;br/&gt;'PT%02dM%02dS' % duration.divmod(60)</description>
      <pubDate>Mon, 17 Mar 2008 16:24:22 -0400</pubDate>
      <link>http://railsloft.com/posts/elegant-non-standard-time-formatting</link>
      <guid>http://railsloft.com/posts/elegant-non-standard-time-formatting-comment-9</guid>
    </item>
  </channel>
</rss>
