Skip to content

Instantly share code, notes, and snippets.

@jschoolcraft
Created July 21, 2011 13:53
Show Gist options
  • Save jschoolcraft/1097236 to your computer and use it in GitHub Desktop.
Save jschoolcraft/1097236 to your computer and use it in GitHub Desktop.
>> dates
=> [#<Date: 2011-07-01 (4911487/2,0,2299161)>, #<Date: 2011-07-20 (4911525/2,0,2299161)>]
>> Date.today - dates.map { |d| Date.today - d }.map(&:to_f).inject { |sum, diff| sum + diff } / dates.length
=> #<Date: 2011-07-10 (2455753.0,0,2299161)>
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment