Issue #14850 has been updated by nobu (Nobuyoshi Nakada).


Here is a [patch] to extend `Time.new` and `Time#getlocal` for timezone support.
A timezone object should have `local_to_utc`, `utc_to_local` and `utc_offset` methods, like [timezone gem].

[patch]: https://github.com/nobu/ruby/tree/feature/14850-timezone
[timezone gem]: https://github.com/panthomakos/timezone

----------------------------------------
Feature #14850: Add official API for setting timezone on Time
https://bugs.ruby-lang.org/issues/14850#change-73852

* Author: sam.saffron (Sam Saffron)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Only way of setting zone on a Time object appears to be via marshalling and messing with ENV. 

```
>> ENV['TZ'] = 'America/New_York'
>> Time.now.zone
=> "EDT"
>> ENV['TZ'] = 'Europe/London'
>> Time.now.zone
=> "BST"
```

Is there any particular reason there is no direct, supported API for setting timezone? 

ActiveSupport carries http://api.rubyonrails.org/v5.1/classes/ActiveSupport/TimeWithZone.html for this exact reason, it would be nice for core Ruby to support this out-of-the-box



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>