Project

General

Profile

Actions

Feature #14850

closed

Add official API for setting timezone on Time

Added by sam.saffron (Sam Saffron) over 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:87507]

Description

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

Actions

Also available in: Atom PDF