Given this hash in ruby:
h={
2010-03-01=>2
2010-03-02=>4
2010=03-03=>1
..
..
n days with working hours
}
where hash key is a date and hash value is an integer, how do I transform this hash into a new hash where keys are weeks/months/years (with aggregation)?
Let me show an example with weeks, the end result should look like:
h_weeks={7=>36, 8=>42, 9=>34 ..,..,n}
with months:
h_months={1=>170, 2=>180, 3=>146}
with years:
h_years={2009=>950, 2010=>446}
where key is a week number(month/year), and value is an aggregate of working hours within this week/month/year.
I'm writing a small working hours tracking application and would like to group this data.
Thanks.