[Feature idea] Truncating timestamp precision

powi
Mon, 06 Oct 2014 12:17:58 -0000

Hello.

I thought of adding a method in ActiveSupport that would be able to
truncate custom precision amounts from a `DateTime` object.

For example:

    DateTime.now.truncate_precision(sec: 10) # => a new DateTime object
minus the specified precision

I've needed this in a feature of mine and thought it might be useful to
others.

What do you think? If we find this useful, I'd prepare a PR soon.

Cheers!

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/97f5ac33-f49f-472e-b8b5-be301767de4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.