Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
54bccc49
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,发现更多精彩内容 >>
提交
54bccc49
编写于
12月 04, 2014
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17913 from claudiob/add-docs-to-time-with-zone
Add documentation to six AS::TimeWithZone methods [ci skip]
上级
f02a1874
d809fc1b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
2 deletion
+23
-2
activesupport/lib/active_support/time_with_zone.rb
activesupport/lib/active_support/time_with_zone.rb
+23
-2
未找到文件。
activesupport/lib/active_support/time_with_zone.rb
浏览文件 @
54bccc49
...
...
@@ -121,16 +121,25 @@ def formatted_offset(colon = true, alternate_utc_string = nil)
utc?
&&
alternate_utc_string
||
TimeZone
.
seconds_to_utc_offset
(
utc_offset
,
colon
)
end
# Time uses +zone+ to display the time zone abbreviation, so we're
# duck-typing it.
# Returns the time zone abbreviation.
#
# Time.zone = 'Eastern Time (US & Canada)' # => "Eastern Time (US & Canada)"
# Time.zone.now.zone # => "EST"
def
zone
period
.
zone_identifier
.
to_s
end
# Returns a string of the object's date, time, zone and offset from UTC.
#
# Time.zone.now.httpdate # => "Thu, 04 Dec 2014 11:00:25 EST -05:00"
def
inspect
"
#{
time
.
strftime
(
'%a, %d %b %Y %H:%M:%S'
)
}
#{
zone
}
#{
formatted_offset
}
"
end
# Returns a string of the object's date and time in the ISO 8601 standard
# format.
#
# Time.zone.now.xmlschema # => "2014-12-04T11:02:37-05:00"
def
xmlschema
(
fraction_digits
=
0
)
fraction
=
if
fraction_digits
.
to_i
>
0
(
".%06i"
%
time
.
usec
)[
0
,
fraction_digits
.
to_i
+
1
]
...
...
@@ -303,15 +312,27 @@ def to_a
[
time
.
sec
,
time
.
min
,
time
.
hour
,
time
.
day
,
time
.
mon
,
time
.
year
,
time
.
wday
,
time
.
yday
,
dst?
,
zone
]
end
# Returns the object's date and time as a floating point number of seconds
# since the Epoch (January 1, 1970 00:00 UTC).
#
# Time.zone.now.to_f # => 1417709320.285418
def
to_f
utc
.
to_f
end
# Returns the object's date and time as an integer number of seconds
# since the Epoch (January 1, 1970 00:00 UTC).
#
# Time.zone.now.to_i # => 1417709320
def
to_i
utc
.
to_i
end
alias_method
:tv_sec
,
:to_i
# Returns the object's date and time as a rational number of seconds
# since the Epoch (January 1, 1970 00:00 UTC).
#
# Time.zone.now.to_r # => (708854548642709/500000)
def
to_r
utc
.
to_r
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录