Posted By

ringo on 07/08/06


Tagged

date textmate humanize


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

alvaroisorna
jpb
bbuckley
youpy
sergeizen
webstic


date humanize


 / Published in: Ruby
 

  1. def entry_date_humanize( t ) # t:TimeDiff
  2. sec = t.to_i
  3. if( sec < 60 ) then
  4. return sec.to_s + \"s\"
  5. elsif( sec < (60*60)) then
  6. return (sec/60).to_s + \"m\"
  7. elsif( sec < (24*60*60)) then
  8. return (sec/60/60).to_s + \"h\"
  9. else
  10. return (sec/24/60/60).to_s + \"d\"
  11. end
  12. end
  13.  

Report this snippet  

You need to login to post a comment.