Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. module AutoTimestamp
  2. def query_callback(rows, options)
  3. rows.each do |r|
  4. r.each do |k, v|
  5. if v.is_a?(Integer)
  6. dates = [ Time.at(v), Time.at(v / 1000) ]
  7. plausible_date = dates.find { |d|
  8. d >= Time.now - 10.years && d <= Time.now + 10.years
  9. }
  10.  
  11. if plausible_date
  12. r[k] = "#{plausible_date.localtime('-07:00').to_s} (#{v})"
  13. end
  14. end
  15. end
  16. end
  17. end
  18. end
  19. Hirb::Helpers::Table.send :include, AutoTimestamp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement