diff --git a/README.md b/README.md index 2899670..4f954f7 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,25 @@ PostgreSQL only at the moment - support for other datastores coming soon ```ruby User.group_by_day(:created_at).count -# => {"2013-04-16 00:00:00+00" => 50, "2013-04-17 00:00:00+00" => 100} +# { +# "2013-04-16 00:00:00+00" => 50, +# "2013-04-17 00:00:00+00" => 100, +# "2013-04-18 00:00:00+00" => 34 +# } Task.group_by_month(:updated_at).count -# => {"2013-03-01 00:00:00+00" => 23, "2013-04-01 00:00:00+00" => 44} +# { +# "2013-02-01 00:00:00+00" => 84, +# "2013-03-01 00:00:00+00" => 23, +# "2013-04-01 00:00:00+00" => 44 +# } Goal.group_by_year(:accomplished_at).count -# => {"2012-01-01 00:00:00+00" => 11, "2013-01-01 00:00:00+00" => 3} +# { +# "2011-01-01 00:00:00+00" => 7, +# "2012-01-01 00:00:00+00" => 11, +# "2013-01-01 00:00:00+00" => 3 +# } ``` The default time zone is `Time.zone`. Pass a time zone as the second argument. @@ -30,7 +42,11 @@ The default time zone is `Time.zone`. Pass a time zone as the second argument. ```ruby time_zone = ActiveSupport::TimeZone["Pacific Time (US & Canada)"] User.group_by_week(:created_at, time_zone).count -# => {"2013-04-16 07:00:00+00" => 80, "2013-04-17 07:00:00+00" => 70} +# { +# "2013-02-25 08:00:00+00" => 80, +# "2013-03-04 08:00:00+00" => 70, +# "2013-03-11 07:00:00+00" => 54 +# } ``` Use it with anything you can use `group` with: -- libgit2 0.21.0