Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
be858689
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,发现更多精彩内容 >>
提交
be858689
编写于
5月 18, 2008
作者:
G
gbuesing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Time#to_json: don't convert to utc before encoding. References #175
上级
0f333449
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
19 addition
and
1 deletion
+19
-1
activesupport/CHANGELOG
activesupport/CHANGELOG
+2
-0
activesupport/lib/active_support/json/encoders/time.rb
activesupport/lib/active_support/json/encoders/time.rb
+1
-1
activesupport/test/json/encoding_test.rb
activesupport/test/json/encoding_test.rb
+16
-0
未找到文件。
activesupport/CHANGELOG
浏览文件 @
be858689
* Time#to_json: don't convert to utc before encoding. References #175 [Geoff Buesing]
*2.1.0 RC1 (May 11th, 2008)*
*2.1.0 RC1 (May 11th, 2008)*
* Remove unused JSON::RESERVED_WORDS, JSON.valid_identifier? and JSON.reserved_word? methods. Resolves #164. [Cheah Chu Yeow]
* Remove unused JSON::RESERVED_WORDS, JSON.valid_identifier? and JSON.reserved_word? methods. Resolves #164. [Cheah Chu Yeow]
...
...
activesupport/lib/active_support/json/encoders/time.rb
浏览文件 @
be858689
...
@@ -6,7 +6,7 @@ class Time
...
@@ -6,7 +6,7 @@ class Time
# # => 2005/02/01 15:15:10 +0000"
# # => 2005/02/01 15:15:10 +0000"
def
to_json
(
options
=
nil
)
def
to_json
(
options
=
nil
)
if
ActiveSupport
.
use_standard_json_time_format
if
ActiveSupport
.
use_standard_json_time_format
utc
.
xmlschema
.
inspect
xmlschema
.
inspect
else
else
%("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}")
%("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}")
end
end
...
...
activesupport/test/json/encoding_test.rb
浏览文件 @
be858689
...
@@ -91,6 +91,15 @@ def test_hash_should_allow_key_filtering_with_except
...
@@ -91,6 +91,15 @@ def test_hash_should_allow_key_filtering_with_except
assert_equal
%({"b": 2})
,
{
'foo'
=>
'bar'
,
:b
=>
2
,
:c
=>
3
}.
to_json
(
:except
=>
[
'foo'
,
:c
])
assert_equal
%({"b": 2})
,
{
'foo'
=>
'bar'
,
:b
=>
2
,
:c
=>
3
}.
to_json
(
:except
=>
[
'foo'
,
:c
])
end
end
def
test_time_to_json_includes_local_offset
ActiveSupport
.
use_standard_json_time_format
=
true
with_env_tz
'US/Eastern'
do
assert_equal
%("2005-02-01T15:15:10-05:00")
,
Time
.
local
(
2005
,
2
,
1
,
15
,
15
,
10
).
to_json
end
ensure
ActiveSupport
.
use_standard_json_time_format
=
false
end
protected
protected
def
with_kcode
(
code
)
def
with_kcode
(
code
)
if
RUBY_VERSION
<
'1.9'
if
RUBY_VERSION
<
'1.9'
...
@@ -108,6 +117,13 @@ def with_kcode(code)
...
@@ -108,6 +117,13 @@ def with_kcode(code)
def
object_keys
(
json_object
)
def
object_keys
(
json_object
)
json_object
[
1
..-
2
].
scan
(
/([^{}:,\s]+):/
).
flatten
.
sort
json_object
[
1
..-
2
].
scan
(
/([^{}:,\s]+):/
).
flatten
.
sort
end
end
def
with_env_tz
(
new_tz
=
'US/Eastern'
)
old_tz
,
ENV
[
'TZ'
]
=
ENV
[
'TZ'
],
new_tz
yield
ensure
old_tz
?
ENV
[
'TZ'
]
=
old_tz
:
ENV
.
delete
(
'TZ'
)
end
end
end
uses_mocha
'JsonOptionsTests'
do
uses_mocha
'JsonOptionsTests'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录