Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
070c2423
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,发现更多精彩内容 >>
提交
070c2423
编写于
7月 03, 2010
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
差异文件
Merge remote branch 'spastorino/master'
上级
54250a5b
075f8b72
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
40 addition
and
30 deletion
+40
-30
activemodel/lib/active_model/errors.rb
activemodel/lib/active_model/errors.rb
+1
-0
activesupport/lib/active_support/core_ext/date/calculations.rb
...esupport/lib/active_support/core_ext/date/calculations.rb
+2
-1
activesupport/lib/active_support/core_ext/date/conversions.rb
...vesupport/lib/active_support/core_ext/date/conversions.rb
+0
-18
activesupport/lib/active_support/core_ext/date/zones.rb
activesupport/lib/active_support/core_ext/date/zones.rb
+21
-0
activesupport/lib/active_support/core_ext/date_time/calculations.rb
...ort/lib/active_support/core_ext/date_time/calculations.rb
+1
-0
activesupport/lib/active_support/core_ext/date_time/conversions.rb
...port/lib/active_support/core_ext/date_time/conversions.rb
+1
-0
activesupport/lib/active_support/core_ext/date_time/zones.rb
activesupport/lib/active_support/core_ext/date_time/zones.rb
+2
-0
activesupport/lib/active_support/core_ext/time/calculations.rb
...esupport/lib/active_support/core_ext/time/calculations.rb
+5
-0
activesupport/lib/active_support/core_ext/time/zones.rb
activesupport/lib/active_support/core_ext/time/zones.rb
+0
-5
activesupport/lib/active_support/time.rb
activesupport/lib/active_support/time.rb
+1
-0
activesupport/lib/active_support/values/time_zone.rb
activesupport/lib/active_support/values/time_zone.rb
+6
-6
未找到文件。
activemodel/lib/active_model/errors.rb
浏览文件 @
070c2423
# -*- coding: utf-8 -*-
require
'active_support/core_ext/array/wrap'
require
'active_support/core_ext/array/conversions'
require
'active_support/core_ext/string/inflections'
require
'active_support/core_ext/object/blank'
require
'active_support/core_ext/hash/reverse_merge'
...
...
activesupport/lib/active_support/core_ext/date/calculations.rb
浏览文件 @
070c2423
require
'date'
require
'active_support/duration'
require
'active_support/core_ext/time/zones'
require
'active_support/core_ext/object/acts_like'
require
'active_support/core_ext/date/zones'
require
'active_support/core_ext/time/zones'
class
Date
if
RUBY_VERSION
<
'1.9'
...
...
activesupport/lib/active_support/core_ext/date/conversions.rb
浏览文件 @
070c2423
require
'date'
require
'active_support/inflector'
require
'active_support/core_ext/time/calculations'
class
Date
DATE_FORMATS
=
{
...
...
@@ -15,9 +14,6 @@ class Date
# Ruby 1.9 has Date#to_time which converts to localtime only.
remove_method
:to_time
if
instance_methods
.
include?
(
:to_time
)
# Ruby 1.9 has Date#xmlschema which converts to a string without the time component.
remove_method
:xmlschema
if
instance_methods
.
include?
(
:xmlschema
)
# Convert to a formatted string. See DATE_FORMATS for predefined formats.
#
# This method is aliased to <tt>to_s</tt>.
...
...
@@ -82,16 +78,6 @@ def to_time(form = :local)
::
Time
.
send
(
"
#{
form
}
_time"
,
year
,
month
,
day
)
end
# Converts Date to a TimeWithZone in the current zone if Time.zone_default is set,
# otherwise converts Date to a Time via Date#to_time
def
to_time_in_current_zone
if
::
Time
.
zone_default
::
Time
.
zone
.
local
(
year
,
month
,
day
)
else
to_time
end
end
# Converts a Date instance to a DateTime, where the time is set to the beginning of the day
# and UTC offset is set to 0.
#
...
...
@@ -102,8 +88,4 @@ def to_time_in_current_zone
def
to_datetime
::
DateTime
.
civil
(
year
,
month
,
day
,
0
,
0
,
0
,
0
)
end
if
RUBY_VERSION
<
'1.9'
def
xmlschema
to_time_in_current_zone
.
xmlschema
end
end
activesupport/lib/active_support/core_ext/date/zones.rb
0 → 100644
浏览文件 @
070c2423
require
'date'
require
'active_support/core_ext/time/zones'
class
Date
# Converts Date to a TimeWithZone in the current zone if Time.zone_default is set,
# otherwise converts Date to a Time via Date#to_time
def
to_time_in_current_zone
if
::
Time
.
zone_default
::
Time
.
zone
.
local
(
year
,
month
,
day
)
else
to_time
end
end
# Ruby 1.9 has Date#xmlschema which converts to a string without the time component.
remove_method
:xmlschema
if
instance_methods
.
include?
(
:xmlschema
)
def
xmlschema
to_time_in_current_zone
.
xmlschema
end
end
activesupport/lib/active_support/core_ext/date_time/calculations.rb
浏览文件 @
070c2423
require
'rational'
unless
RUBY_VERSION
>=
'1.9.2'
require
'active_support/core_ext/object/acts_like'
require
'active_support/core_ext/time/zones'
class
DateTime
class
<<
self
...
...
activesupport/lib/active_support/core_ext/date_time/conversions.rb
浏览文件 @
070c2423
require
'active_support/inflector'
require
'active_support/core_ext/time/conversions'
require
'active_support/core_ext/date_time/calculations'
require
'active_support/values/time_zone'
class
DateTime
# Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows
...
...
activesupport/lib/active_support/core_ext/date_time/zones.rb
浏览文件 @
070c2423
require
'active_support/core_ext/time/zones'
class
DateTime
# Returns the simultaneous time in <tt>Time.zone</tt>.
#
...
...
activesupport/lib/active_support/core_ext/time/calculations.rb
浏览文件 @
070c2423
...
...
@@ -40,6 +40,11 @@ def utc_time(*args)
def
local_time
(
*
args
)
time_with_datetime_fallback
(
:local
,
*
args
)
end
# Returns <tt>Time.zone.now</tt> when <tt>config.time_zone</tt> is set, otherwise just returns <tt>Time.now</tt>.
def
current
::
Time
.
zone_default
?
::
Time
.
zone
.
now
:
::
Time
.
now
end
end
# Tells whether the Time object's time lies in the past
...
...
activesupport/lib/active_support/core_ext/time/zones.rb
浏览文件 @
070c2423
...
...
@@ -41,11 +41,6 @@ def use_zone(time_zone)
::
Time
.
zone
=
old_zone
end
# Returns <tt>Time.zone.now</tt> when <tt>config.time_zone</tt> is set, otherwise just returns <tt>Time.now</tt>.
def
current
::
Time
.
zone_default
?
::
Time
.
zone
.
now
:
::
Time
.
now
end
private
def
get_zone
(
time_zone
)
return
time_zone
if
time_zone
.
nil?
||
time_zone
.
is_a?
(
ActiveSupport
::
TimeZone
)
...
...
activesupport/lib/active_support/time.rb
浏览文件 @
070c2423
...
...
@@ -24,6 +24,7 @@ module ActiveSupport
require
'active_support/core_ext/date/freeze'
require
'active_support/core_ext/date/calculations'
require
'active_support/core_ext/date/conversions'
require
'active_support/core_ext/date/zones'
require
'active_support/core_ext/date_time/acts_like'
require
'active_support/core_ext/date_time/calculations'
...
...
activesupport/lib/active_support/values/time_zone.rb
浏览文件 @
070c2423
require
'active_support/core_ext/object/blank'
require
'active_support/core_ext/object/try'
begin
require
'tzinfo'
rescue
LoadError
=>
e
$stderr
.
puts
"You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
raise
e
end
# The TimeZone class serves as a wrapper around TZInfo::Timezone instances. It allows us to do the following:
#
...
...
@@ -201,6 +195,12 @@ def self.seconds_to_utc_offset(seconds, colon = true)
# (GMT). Seconds were chosen as the offset unit because that is the unit that
# Ruby uses to represent time zone offsets (see Time#utc_offset).
def
initialize
(
name
,
utc_offset
=
nil
,
tzinfo
=
nil
)
begin
require
'tzinfo'
rescue
LoadError
=>
e
$stderr
.
puts
"You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
raise
e
end
@name
=
name
@utc_offset
=
utc_offset
@tzinfo
=
tzinfo
||
TimeZone
.
find_tzinfo
(
name
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录