From: nobu@... Date: 2018-09-02T15:47:24+00:00 Subject: [ruby-core:88809] [Ruby trunk Feature#14850] Add official API for setting timezone on Time 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: