Skip to content

Commit

Permalink
Merge pull request #51017 from p8/activesupport/document-time-zone-cr…
Browse files Browse the repository at this point in the history
…eate

Improve documentation of ActiveSupport::TimeZone.create [ci-skip]
  • Loading branch information
rafaelfranca committed Feb 9, 2024
2 parents fbb230e + 15b4595 commit efa8889
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions activesupport/lib/active_support/values/time_zone.rb
Expand Up @@ -208,7 +208,9 @@ def find_tzinfo(name)
TZInfo::Timezone.get(MAPPING[name] || name)
end

# :stopdoc:
alias_method :create, :new
# :startdoc:

# Returns a TimeZone instance with the given name, or +nil+ if no
# such TimeZone instance exists. (This exists to support the use of
Expand Down Expand Up @@ -296,15 +298,22 @@ def zones_map
attr_reader :name
attr_reader :tzinfo

##
# :singleton-method: create
# :call-seq: create(name, utc_offset = nil, tzinfo = nil)
#
# Create a new TimeZone object with the given name and offset. The
# offset is the number of seconds that this time zone is offset from UTC
# (GMT). Seconds were chosen as the offset unit because that is the unit
# that Ruby uses to represent time zone offsets (see Time#utc_offset).

# :stopdoc:
def initialize(name, utc_offset = nil, tzinfo = nil)
@name = name
@utc_offset = utc_offset
@tzinfo = tzinfo || TimeZone.find_tzinfo(name)
end
# :startdoc:

# Returns the offset of this time zone from UTC in seconds.
def utc_offset
Expand Down

0 comments on commit efa8889

Please sign in to comment.