Bug #8376
closed
utc method changes original time object
Added by arjan0307 (Arjan Diepenbroek) almost 11 years ago.
Updated almost 11 years ago.
Description
The utc method changes the original time object when called.
For example when on a system with a CET timezone.
t = Time.new(2013)
t.zone # CET
t.utc
t.zone # UTC
- Status changed from Open to Rejected
Time#utc is destructive method.
Use dup if you want a copy.
naruse (Yui NARUSE) wrote:
Time#utc is destructive method.
Use dup if you want a copy.
That seems the point of this issue. The behaviour is inconsistent. t.utc!
should be the way to destroy t
in the example. This should be changed... ruby isn't PHP.
I admit this is a bad design, but changing it introduces incompatibility.
We don't consider it as a bug (thus we rejected).
Submit feature request instead, if you really want to change.
Maybe fixed in the future, if we can provide proper migration path.
Matz.
You can use Time#getutc or #getgm.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0