Commit 4a842ecdbc1551abc517fcdb6d5951a29cdecbed

Authored by Andrew Kane
1 parent 2f0cb928

Better format example

Showing 1 changed file with 17 additions and 2 deletions   Show diff stats
README.md
... ... @@ -129,12 +129,27 @@ or
129 129 User.group_by_day(:created_at).order("day desc").count
130 130 ```
131 131  
132   -### Pretty Keys
  132 +### Format
133 133  
134 134 To get keys in a different format, use:
135 135  
136 136 ```ruby
137   -User.group_by_hour_of_day(:created_at, format: "%l %P").count.keys.first # 12 am
  137 +User.group_by_day(:created_at, format: "%b %-e, %Y").count
  138 +# {
  139 +# "Jan 1, 2015" => 10
  140 +# "Jan 2, 2015" => 12
  141 +# }
  142 +```
  143 +
  144 +or
  145 +
  146 +```ruby
  147 +User.group_by_hour_of_day(:created_at, format: "%-l %P").count
  148 +# {
  149 +# "12 am" => 15,
  150 +# "1 am" => 11
  151 +# ...
  152 +# }
138 153 ```
139 154  
140 155 Takes a `String`, which is passed to [strftime](http://strfti.me/), or a `Proc`. You can pass a locale with the `locale` option.
... ...