Movatterモバイル変換


[0]ホーム

URL:


Skip to ContentSkip to Search
Ruby on Rails 8.1.1

Module DateAndTime::Zones

v8.1.1
Methods
I

Instance Public methods

in_time_zone(zone = ::Time.zone)Link

Returns the simultaneous time inTime.zone if a zone is given or ifTime.zone_default is set. Otherwise, it returns the current time.

Time.zone ='Hawaii'# => 'Hawaii'Time.utc(2000).in_time_zone# => Fri, 31 Dec 1999 14:00:00 HST -10:00Date.new(2000).in_time_zone# => Sat, 01 Jan 2000 00:00:00 HST -10:00

This method is similar to Time#localtime, except that it usesTime.zone as the local zone instead of the operating system’s time zone.

You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument, and the conversion will be based on that zone instead ofTime.zone.

Time.utc(2000).in_time_zone('Alaska')# => Fri, 31 Dec 1999 15:00:00 AKST -09:00Date.new(2000).in_time_zone('Alaska')# => Sat, 01 Jan 2000 00:00:00 AKST -09:00

Source:show |on GitHub

# File activesupport/lib/active_support/core_ext/date_and_time/zones.rb, line 20defin_time_zone(zone =::Time.zone)time_zone =::Time.find_zone!zonetime =acts_like?(:time)?self:niliftime_zonetime_with_zone(time,time_zone)elsetime||to_timeendend

[8]ページ先頭

©2009-2025 Movatter.jp