RubyHitSquad: January 2009 Archives

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

Reservoir Nerds

| | Comments (0)

ReservoirNerds.png

Mr. Black, Mr. White, Mr. Pink, and Mr. Blonde are immediately available for hire. Package deal. 49 years of programming experience, 28 in Ruby. You know their names. Get in touch.

About this Archive

This page is a archive of entries in the RubyHitSquad category from January 2009.

RubyHitSquad: March 2008 is the previous archive.

RubyHitSquad: February 2009 is the next archive.

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

Pages

Powered by Movable Type 4.32-en