Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e3c382e3
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e3c382e3
编写于
1月 26, 2014
作者:
A
Andrew White
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename subsecond_fraction_digits option to time_precision
上级
ef172251
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
10 addition
and
8 deletion
+10
-8
activesupport/lib/active_support/json/encoding.rb
activesupport/lib/active_support/json/encoding.rb
+4
-4
activesupport/lib/active_support/time_with_zone.rb
activesupport/lib/active_support/time_with_zone.rb
+1
-1
activesupport/test/json/encoding_test.rb
activesupport/test/json/encoding_test.rb
+3
-3
guides/source/configuring.md
guides/source/configuring.md
+2
-0
未找到文件。
activesupport/lib/active_support/json/encoding.rb
浏览文件 @
e3c382e3
...
...
@@ -4,7 +4,7 @@
module
ActiveSupport
class
<<
self
delegate
:use_standard_json_time_format
,
:use_standard_json_time_format
=
,
:
subsecond_fraction_digits
,
:subsecond_fraction_digits
=
,
:
time_precision
,
:time_precision
=
,
:escape_html_entities_in_json
,
:escape_html_entities_in_json
=
,
:encode_big_decimal_as_string
,
:encode_big_decimal_as_string
=
,
:json_encoder
,
:json_encoder
=
,
...
...
@@ -106,9 +106,9 @@ class << self
# as a safety measure.
attr_accessor
:escape_html_entities_in_json
#
Configures the inclusion of subsecond resolution when serializing instances
#
of ActiveSupport::TimeWithZone.
attr_accessor
:
subsecond_fraction_digits
#
Sets the precision of encoded time values.
#
Defaults to 3 (equivalent to millisecond precision)
attr_accessor
:
time_precision
# Sets the encoder used by Rails to encode Ruby objects into JSON strings
# in +Object#to_json+ and +ActiveSupport::JSON.encode+.
...
...
activesupport/lib/active_support/time_with_zone.rb
浏览文件 @
e3c382e3
...
...
@@ -154,7 +154,7 @@ def xmlschema(fraction_digits = 0)
# # => "2005/02/01 05:15:10 -1000"
def
as_json
(
options
=
nil
)
if
ActiveSupport
::
JSON
::
Encoding
.
use_standard_json_time_format
digits
=
ActiveSupport
::
JSON
::
Encoding
.
subsecond_fraction_digits
||
3
digits
=
ActiveSupport
::
JSON
::
Encoding
.
time_precision
||
3
xmlschema
(
digits
)
else
%(#{time.strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)})
...
...
activesupport/test/json/encoding_test.rb
浏览文件 @
e3c382e3
...
...
@@ -466,15 +466,15 @@ def test_twz_to_json_with_use_standard_json_time_format_config_set_to_true
end
end
def
test_twz_to_json_with_custom_
subsecond_resolut
ion
def
test_twz_to_json_with_custom_
time_precis
ion
with_standard_json_time_format
(
true
)
do
ActiveSupport
::
JSON
::
Encoding
.
subsecond_fraction_digits
=
0
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
0
zone
=
ActiveSupport
::
TimeZone
[
'Eastern Time (US & Canada)'
]
time
=
ActiveSupport
::
TimeWithZone
.
new
(
Time
.
utc
(
2000
),
zone
)
assert_equal
"
\"
1999-12-31T19:00:00-05:00
\"
"
,
ActiveSupport
::
JSON
.
encode
(
time
)
end
ensure
ActiveSupport
::
JSON
::
Encoding
.
subsecond_fraction_digits
=
nil
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
nil
end
def
test_twz_to_json_when_wrapping_a_date_time
...
...
guides/source/configuring.md
浏览文件 @
e3c382e3
...
...
@@ -441,6 +441,8 @@ There are a few configuration options available in Active Support:
*
`config.active_support.use_standard_json_time_format`
enables or disables serializing dates to ISO 8601 format. Defaults to
`true`
.
*
`config.active_support.time_precision`
sets the precision of JSON encoded time values. Defaults to
`3`
.
*
`ActiveSupport::Logger.silencer`
is set to
`false`
to disable the ability to silence logging in a block. The default is
`true`
.
*
`ActiveSupport::Cache::Store.logger`
specifies the logger to use within cache store operations.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录