<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: time code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 23 Jul 2008 18:27:32 GMT</pubDate>
    <description>DZone Snippets: time code</description>
    <item>
      <title>Ruby method to get seconds from colon-separated time string</title>
      <link>http://snippets.dzone.com/posts/show/1137</link>
      <description>// converts colon-separated time to seconds&lt;br /&gt;// "01:02:03" =&gt; 3723&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def colon_separated_to_i(str)&lt;br /&gt;&lt;br /&gt;  time_arr = []&lt;br /&gt;  time_arr = str.split(":").reverse&lt;br /&gt;  sec = 0&lt;br /&gt;  secs = [1, 60, 60*60, 60*60*24]&lt;br /&gt;&lt;br /&gt;  time_arr.size.times do {|i|&lt;br /&gt;    sec += secs[i].to_i * time_arr[i].to_i&lt;br /&gt;  end&lt;br /&gt;  sec&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 12 Jan 2006 01:05:37 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1137</guid>
      <author>kelyar (Kelyarsky Evgeniy)</author>
    </item>
  </channel>
</rss>
