rails

https://github.com/rails/rails

Ruby

Ruby on Rails

ActiveSupport::TimeWithZone#change

Returns a new +ActiveSupport::TimeWithZone+ where one or more of the elements have
been changed according to the +options+ parameter. The time options (<tt>:hour</tt>,
<tt>:min</tt>, <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly,
so if only the hour is passed, then minute, sec, usec and nsec is set to 0. If the
hour and minute is passed, then sec, usec and nsec is set to 0. The +options+
parameter takes a hash with any of these keys: <tt>:year</tt>, <tt>:month</tt>,
<tt>:day</tt>, <tt>:hour</tt>, <tt>:min</tt>, <tt>:sec</tt>, <tt>:usec</tt>,
<tt>:nsec</tt>, <tt>:offset</tt>, <tt>:zone</tt>. Pass either <tt>:usec</tt>
or <tt>:nsec</tt>, not both. Similarly, pass either <tt>:zone</tt> or
<tt>:offset</tt>, not both.

  t = Time.zone.now          # => Fri, 14 Apr 2017 11:45:15 EST -05:00
  t.change(year: 2020)       # => Tue, 14 Apr 2020 11:45:15 EST -05:00
  t.change(hour: 12)         # => Fri, 14 Apr 2017 12:00:00 EST -05:00
  t.change(min: 30)          # => Fri, 14 Apr 2017 11:30:00 EST -05:00
  t.change(offset: "-10:00") # => Fri, 14 Apr 2017 11:45:15 HST -10:00
  t.change(zone: "Hawaii")   # => Fri, 14 Apr 2017 11:45:15 HST -10:00

Source | Google | Stack overflow

Edit

git clone [email protected]:rails/rails.git

cd rails

open activesupport/lib/active_support/time_with_zone.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-ActiveSupport--TimeWithZone-change-for-pr


# Commit to git

git add activesupport/lib/active_support/time_with_zone.rbgit commit -m "better docs for ActiveSupport::TimeWithZone#change"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-ActiveSupport--TimeWithZone-change-for-pr

hub pull-request


# Celebrate!