From 4a842ecdbc1551abc517fcdb6d5951a29cdecbed Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 29 Sep 2015 00:02:37 -0700 Subject: [PATCH] Better format example --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e45e7a1..4bb8716 100644 --- a/README.md +++ b/README.md @@ -129,12 +129,27 @@ or User.group_by_day(:created_at).order("day desc").count ``` -### Pretty Keys +### Format To get keys in a different format, use: ```ruby -User.group_by_hour_of_day(:created_at, format: "%l %P").count.keys.first # 12 am +User.group_by_day(:created_at, format: "%b %-e, %Y").count +# { +# "Jan 1, 2015" => 10 +# "Jan 2, 2015" => 12 +# } +``` + +or + +```ruby +User.group_by_hour_of_day(:created_at, format: "%-l %P").count +# { +# "12 am" => 15, +# "1 am" => 11 +# ... +# } ``` Takes a `String`, which is passed to [strftime](http://strfti.me/), or a `Proc`. You can pass a locale with the `locale` option. -- libgit2 0.21.0