<?xml version="1.0" encoding="UTF-8"?>
<code>
  <code>def sec_to_time(sec)
	t = Hash.new
	a_sec = sec.divmod(60)
	s = a_sec[1]
	a_min = a_sec[0].divmod(60)
	m = a_min[1]
	a_h = a_min[0].divmod(24)
	h = a_h[1]
	t["secondes"],t["minutes"],t["heures"]= s,m,h

	return t
end

def time_to_sec(t)
	sec = t["secondes"] + (t["minutes"] * 60) + (t["heures"] * 60 * 60)
	return sec
end</code>
  <comment>I have a time in second and a Hash with seconds minutes and hours.
I'm sure you have some pretty tricks </comment>
  <created-at type="datetime">2008-06-11T21:21:49+00:00</created-at>
  <id type="integer">317</id>
  <language>Ruby</language>
  <permalink>time-to-second-second-to-time</permalink>
  <refactors-count type="integer">2</refactors-count>
  <title>time to second, second to time</title>
  <trackback-url></trackback-url>
  <updated-at type="datetime">2008-06-11T23:42:48+00:00</updated-at>
  <user-id type="integer">637</user-id>
  <refactors type="array">
    <refactor>
      <code>&gt;&gt; start = Time.at 0
=&gt; Wed Dec 31 19:00:00 -0500 1969
&gt;&gt; later = start + 60 * 60 * 2 + 60 * 3 + 1 # add 2 hours, 3 minutes and 1 second
=&gt; Wed Dec 31 21:01:01 -0500 1969
&gt;&gt; later.hour - start.hour
=&gt; 2
&gt;&gt; later.min  - start.min
=&gt; 3
&gt;&gt; later.sec - start.sec
=&gt; 1
</code>
      <code-id type="integer">317</code-id>
      <comment>Why not just use Time ?</comment>
      <created-at type="datetime">2008-06-11T21:44:20+00:00</created-at>
      <id type="integer">10292</id>
      <language>Ruby</language>
      <rating type="integer">4</rating>
      <ratings-count type="integer">1</ratings-count>
      <title>On time to second, second to time</title>
      <user-id type="integer">3</user-id>
      <user-name>danielharan</user-name>
      <user-website>http://danielharan.com/</user-website>
    </refactor>
    <refactor>
      <code></code>
      <code-id type="integer">317</code-id>
      <comment>I got a  "xx:xx:xx", I add some second to it and then write it back.
So I don't found Time very usefull.
a atime.hms could be nice

I use this piece of code to modify a .srt to syncronise it with a video when it needs the knife :)</comment>
      <created-at type="datetime">2008-06-11T23:42:46+00:00</created-at>
      <id type="integer">10302</id>
      <language>Ruby</language>
      <rating type="integer">0</rating>
      <ratings-count type="integer">0</ratings-count>
      <title>On time to second, second to time</title>
      <user-id type="integer">637</user-id>
      <user-name>kyzh</user-name>
      <user-website></user-website>
    </refactor>
  </refactors>
</code>
