[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-core
Subject:    [ruby-core:89607] [Ruby trunk Feature#14850] Add official API for setting timezone on Time
From:       nobu () ruby-lang ! org
Date:       2018-10-28 12:03:38
Message-ID: redmine.journal-74644.20181028120337.5efd91e183ff27b1 () ruby-lang ! org
[Download RAW message or body]

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


Here're my plans.

> ## timezone argument to `Time.at`
> 
> `Time.at` already has the fraction second and its unit arguments.
> To add another optional argument feels complicated, or a keyword argument?

To add `in` keyword argument.

```ruby
Time.at(1540000000, in: Timezone.fetch("Asia/Colombo")) #=> 2018-10-20 07:16:40 +0530
```

> ## look-up timezone by the name
> 
> With "tzinfo" gem, `Time.new(Y, M, D, h, m, s, TZInfo::Timezone.get(zone_name))`, \
> and with "timeone" gem, `Time.new(Y, M, D, h, m, s, Timezone[zone_name])` are \
> possible but not handy. `Time.new(Y, M, D, h, m, s, zone_name)` feels preferable, \
> but I don't want to couple them tightly.

If `find_timezone` class method is defined, it will be called with the `zone_name` \
argument.

Any options?
If no objection, I'll commit the above features.

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

* Author: sam.saffron (Sam Saffron)
* Status: Closed
* 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>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic