Skip to content

Commit 2329975

Browse files
authored
docs: use as_json per method instead of to_json
The docs usage should align with the method. Here are the examples: ``` [29] pry(main)> ActiveSupport::JSON::Encoding.use_standard_json_time_format = true => true [30] pry(main)> Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").to_json => "\"2005-02-01T05:15:10.000-10:00\"" [31] pry(main)> Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").as_json => "2005-02-01T05:15:10.000-10:00" [32] pry(main)> ActiveSupport::JSON::Encoding.use_standard_json_time_format = false => false [33] pry(main)> Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").as_json => "2005/02/01 05:15:10 -1000" [34] pry(main)> Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").to_json => "\"2005/02/01 05:15:10 -1000\"" ```
1 parent d5faea5 commit 2329975

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

activesupport/lib/active_support/time_with_zone.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ def xmlschema(fraction_digits = 0)
157157
# to +false+.
158158
#
159159
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true
160-
# Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").to_json
160+
# Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").as_json
161161
# # => "2005-02-01T05:15:10.000-10:00"
162162
#
163163
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
164-
# Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").to_json
164+
# Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").as_json
165165
# # => "2005/02/01 05:15:10 -1000"
166166
def as_json(options = nil)
167167
if ActiveSupport::JSON::Encoding.use_standard_json_time_format

0 commit comments

Comments
 (0)