Reservoir Nerds, pt 2

| | Comments (1)

ReservoirNerds.png

>> require 'time'
=> true
>> t0 = Time.parse "January 22, 2009 12:05:56 PM"
=> Thu Jan 22 12:05:56 -0800 2009
>> t1 = Time.parse "January 30, 2009 5:30:48 PM"
=> Fri Jan 30 17:30:48 -0800 2009
>> t = (t1 - t0).to_i
=> 710692
>> u = []
=> []
>> [86400, 3600, 60, 1].inject(t) { |t, n| m = t / n; u << m if m != 0; t % n }
=> 0
>> puts u.map {|t| '%02d' % t }.join(":").sub(/^0/, '')
8:05:24:52

1 Comments

'grats. It'll be fun seeing you guys work on the next project over.

Leave a comment

About this Entry

This page contains a single entry by zenspider published on January 31, 2009 11:34 AM.

Reservoir Nerds was the previous entry in this blog.

Reservoir Nerds, pt 3 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.32-en