In rails 3 there is distance_of_time_in_words which works fine, but I would like to tweak its output a bit. The thing is that if the dates are exactly the same it will say "Less Than a Minute" I would like it to show "Today" instead. Is that possible? Tiago Veloso ti.veloso-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> In rails 3 there is distance_of_time_in_words which works fine, but I would like to tweak its output a bit. > > The thing is that if the dates are exactly the same it will say "Less Than a Minute" I would like it to show "Today" instead. > > Is that possible?Write your own method that wraps this one. Compare the dates yourself and if they are < 1 minute spit out "Today" otherwise spit out the result of the original method... That''s what I''d do anyway... -philip -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>> In rails 3 there is distance_of_time_in_words which works fine, but I would like to tweak its output a bit. >> >> The thing is that if the dates are exactly the same it will say "Less Than a Minute" I would like it to show "Today" instead. >> >> Is that possible? > > Write your own method that wraps this one. Compare the dates yourself and if they are < 1 minute spit out "Today" otherwise spit out the result of the original method... > > That''s what I''d do anyway...Or see if that method uses locale files that you can overwrite the value for "Less Than A Minute"... -philip -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It does indeed. It''s in ActionView: en: datetime: distance_in_words: half_a_minute: "half a minute" less_than_x_seconds: one: "less than 1 second" other: "less than %{count} seconds" x_seconds: one: "1 second" other: "%{count} seconds" less_than_x_minutes: one: "less than a minute" other: "less than %{count} minutes" https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you. I have overridden the method. And added a custom key. I prefer not to change the defaults. Tiago Veloso ti.veloso-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org On May 23, 2011, at 20:57 , Tim Shaffer wrote:> It does indeed. It''s in ActionView: > > en: > datetime: > distance_in_words: > half_a_minute: "half a minute" > less_than_x_seconds: > one: "less than 1 second" > other: "less than %{count} seconds" > x_seconds: > one: "1 second" > other: "%{count} seconds" > less_than_x_minutes: > one: "less than a minute" > other: "less than %{count} minutes" > > https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Maybe Matching Threads
- [R-sig-Geo] How to extract coordinates values from a shapefile?
- distance_of_time_in_words hardcoded strings should be separated for easier localization
- How to get difference between two dates in days???
- distance_of_time_in_words shows {{count}} days instead of showing actual days
- Hangups after voicemail