Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
6582eba1
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6582eba1
编写于
9月 08, 2017
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix parseDate, consider DST
上级
8d6b6776
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
27 deletion
+48
-27
src/scale/Time.js
src/scale/Time.js
+4
-4
src/util/number.js
src/util/number.js
+42
-21
test/timeZone.html
test/timeZone.html
+2
-2
未找到文件。
src/scale/Time.js
浏览文件 @
6582eba1
...
...
@@ -77,7 +77,7 @@ define(function (require) {
// If there are no data and extent are [Infinity, -Infinity]
if
(
extent
[
1
]
===
-
Infinity
&&
extent
[
0
]
===
Infinity
)
{
var
d
=
new
Date
();
extent
[
1
]
=
new
Date
(
d
.
getFullYear
(),
d
.
getMonth
(),
d
.
getDate
());
extent
[
1
]
=
+
new
Date
(
d
.
getFullYear
(),
d
.
getMonth
(),
d
.
getDate
());
extent
[
0
]
=
extent
[
1
]
-
ONE_DAY
;
}
...
...
@@ -98,8 +98,6 @@ define(function (require) {
* @override
*/
niceTicks
:
function
(
approxTickNum
,
minInterval
,
maxInterval
)
{
var
timezoneOffset
=
this
.
getSetting
(
'
useUTC
'
)
?
0
:
numberUtil
.
getTimezoneOffset
()
*
60
*
1000
;
approxTickNum
=
approxTickNum
||
10
;
var
extent
=
this
.
_extent
;
...
...
@@ -129,9 +127,11 @@ define(function (require) {
interval
*=
yearStep
;
}
var
timezoneOffset
=
this
.
getSetting
(
'
useUTC
'
)
?
0
:
(
new
Date
(
+
extent
[
0
]
||
+
extent
[
1
])).
getTimezoneOffset
()
*
60
*
1000
;
var
niceExtent
=
[
Math
.
round
(
mathCeil
((
extent
[
0
]
-
timezoneOffset
)
/
interval
)
*
interval
+
timezoneOffset
),
Math
.
round
(
mathFloor
((
extent
[
1
]
-
timezoneOffset
)
/
interval
)
*
interval
+
timezoneOffset
)
Math
.
round
(
mathFloor
((
extent
[
1
]
-
timezoneOffset
)
/
interval
)
*
interval
+
timezoneOffset
)
];
scaleHelper
.
fixExtent
(
niceExtent
,
extent
);
...
...
src/util/number.js
浏览文件 @
6582eba1
...
...
@@ -273,11 +273,14 @@ define(function (require) {
var
TIME_REG
=
/^
(?:(\d{4})(?:[
-
\/](\d{1,2})(?:[
-
\/](\d{1,2})(?:[
T
](\d{1,2})(?:
:
(\d\d)(?:
:
(\d\d)(?:[
.,
](\d
+
))?)?)?(
Z|
[\+\-]\d\d
:
?\d\d)?)?)?)?)?
$/
;
// jshint ignore:line
/**
* Consider DST, it is incorrect to provide a method `getTimezoneOffset`
* without time specified. So this method is removed.
*
* @return {number} in minutes
*/
number
.
getTimezoneOffset
=
function
()
{
return
(
new
Date
()).
getTimezoneOffset
();
};
//
number.getTimezoneOffset = function () {
//
return (new Date()).getTimezoneOffset();
//
};
/**
* @param {string|Date|number} value These values can be accepted:
...
...
@@ -311,24 +314,42 @@ define(function (require) {
return
new
Date
(
NaN
);
}
var
timezoneOffset
=
number
.
getTimezoneOffset
();
var
timeOffset
=
!
match
[
8
]
?
0
:
match
[
8
].
toUpperCase
()
===
'
Z
'
?
timezoneOffset
:
+
match
[
8
].
slice
(
0
,
3
)
*
60
+
timezoneOffset
;
// match[n] can only be string or undefined.
// But take care of '12' + 1 => '121'.
return
new
Date
(
+
match
[
1
],
+
(
match
[
2
]
||
1
)
-
1
,
+
match
[
3
]
||
1
,
+
match
[
4
]
||
0
,
+
(
match
[
5
]
||
0
)
-
timeOffset
,
+
match
[
6
]
||
0
,
+
match
[
7
]
||
0
);
// Use local time when no timezone offset specifed.
if
(
!
match
[
8
])
{
// match[n] can only be string or undefined.
// But take care of '12' + 1 => '121'.
return
new
Date
(
+
match
[
1
],
+
(
match
[
2
]
||
1
)
-
1
,
+
match
[
3
]
||
1
,
+
match
[
4
]
||
0
,
+
(
match
[
5
]
||
0
),
+
match
[
6
]
||
0
,
+
match
[
7
]
||
0
);
}
// Timezoneoffset of Javascript Date has considered DST (Daylight Saving Time,
// https://tc39.github.io/ecma262/#sec-daylight-saving-time-adjustment).
// For example, system timezone is set as "Time Zone: America/Toronto",
// then these code will get different result:
// `new Date(1478411999999).getTimezoneOffset(); // get 240`
// `new Date(1478412000000).getTimezoneOffset(); // get 300`
// So we should not use `new Date`, but use `Date.UTC`.
else
{
var
hour
=
+
match
[
4
]
||
0
;
if
(
match
[
8
].
toUpperCase
()
!==
'
Z
'
)
{
hour
-=
match
[
8
].
slice
(
0
,
3
);
}
return
new
Date
(
Date
.
UTC
(
+
match
[
1
],
+
(
match
[
2
]
||
1
)
-
1
,
+
match
[
3
]
||
1
,
hour
,
+
(
match
[
5
]
||
0
),
+
match
[
6
]
||
0
,
+
match
[
7
]
||
0
));
}
}
else
if
(
value
==
null
)
{
return
new
Date
(
NaN
);
...
...
test/timeZone.html
浏览文件 @
6582eba1
...
...
@@ -22,10 +22,10 @@
</style>
<h1>
time scale label shoul
e
in local time when timestamp (in UTC) input, tick should align with day.
</h1>
<h1>
time scale label shoul
d
in local time when timestamp (in UTC) input, tick should align with day.
</h1>
<div
class=
"chart"
id=
"chart0"
></div>
<h1>
time scale label shoul
e
in UTC time when option.useUTC is `true`, tick should not align with day.
</h1>
<h1>
time scale label shoul
d
in UTC time when option.useUTC is `true`, tick should not align with day.
</h1>
<div
class=
"chart"
id=
"chart1"
></div>
<h1>
useUTC: null, should display '00:00 01-03' in tooltip on the 1st point
</h1>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录