mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
added isoDate parse to parseYear method
This commit is contained in:
parent
ab0178da02
commit
57d615d073
@ -379,6 +379,9 @@ class Morris.Line
|
||||
p = date.match /^(\d+) W(\d+)$/
|
||||
q = date.match /^(\d+)-(\d+)-(\d+) (\d+):(\d+)$/
|
||||
r = date.match /^(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+(\.\d+)?)$/
|
||||
# parse isoDate like '2012-03-09T21:59:08'
|
||||
# pattern from http://webcloud.se/log/JavaScript-and-ISO-8601/
|
||||
z = date.match /^([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?$/
|
||||
if m
|
||||
new Date(
|
||||
parseInt(m[1], 10),
|
||||
@ -421,6 +424,13 @@ class Morris.Line
|
||||
parseInt(r[5], 10),
|
||||
isecs,
|
||||
msecs).getTime()
|
||||
else if z
|
||||
new Date(
|
||||
parseInt(z[1], 10),
|
||||
parseInt(z[3], 10) - 1,
|
||||
parseInt(z[5], 10),
|
||||
parseInt(z[7], 10),
|
||||
parseInt(z[8], 10)).getTime()
|
||||
else
|
||||
new Date(parseInt(date, 10), 0, 1)
|
||||
|
||||
|
@ -437,7 +437,7 @@
|
||||
};
|
||||
|
||||
Line.prototype.parseYear = function(date) {
|
||||
var isecs, m, msecs, n, o, p, q, r, ret, secs;
|
||||
var isecs, m, msecs, n, o, p, q, r, ret, secs, z;
|
||||
if (typeof date === 'number') return date;
|
||||
m = date.match(/^(\d+) Q(\d)$/);
|
||||
n = date.match(/^(\d+)-(\d+)$/);
|
||||
@ -445,6 +445,7 @@
|
||||
p = date.match(/^(\d+) W(\d+)$/);
|
||||
q = date.match(/^(\d+)-(\d+)-(\d+) (\d+):(\d+)$/);
|
||||
r = date.match(/^(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+(\.\d+)?)$/);
|
||||
z = date.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?$/);
|
||||
if (m) {
|
||||
return new Date(parseInt(m[1], 10), parseInt(m[2], 10) * 3 - 1, 1).getTime();
|
||||
} else if (n) {
|
||||
@ -462,6 +463,8 @@
|
||||
isecs = Math.floor(secs);
|
||||
msecs = Math.floor((secs - isecs) * 1000);
|
||||
return new Date(parseInt(r[1], 10), parseInt(r[2], 10) - 1, parseInt(r[3], 10), parseInt(r[4], 10), parseInt(r[5], 10), isecs, msecs).getTime();
|
||||
} else if (z) {
|
||||
return new Date(parseInt(z[1], 10), parseInt(z[3], 10) - 1, parseInt(z[5], 10), parseInt(z[7], 10), parseInt(z[8], 10)).getTime();
|
||||
} else {
|
||||
return new Date(parseInt(date, 10), 0, 1);
|
||||
}
|
||||
|
2
morris.min.js
vendored
2
morris.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user