mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
Merge branch 'master' of https://github.com/littlebtc/morris.js into timezones
Conflicts: morris.coffee morris.js morris.min.js
This commit is contained in:
commit
870e0a649a
@ -382,8 +382,8 @@ Morris.parseDate = (date) ->
|
||||
n = date.match /^(\d+)-(\d+)$/
|
||||
o = date.match /^(\d+)-(\d+)-(\d+)$/
|
||||
p = date.match /^(\d+) W(\d+)$/
|
||||
q = date.match /^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)Z?$/
|
||||
r = date.match /^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)Z?$/
|
||||
q = date.match /^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d+):(\d+))?$/
|
||||
r = date.match /^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d+):(\d+))?$/
|
||||
if m
|
||||
new Date(
|
||||
parseInt(m[1], 10),
|
||||
@ -408,24 +408,32 @@ Morris.parseDate = (date) ->
|
||||
# add weeks
|
||||
ret.getTime() + parseInt(p[2], 10) * 604800000
|
||||
else if q
|
||||
new Date(
|
||||
offsetmins = 0
|
||||
if q[6] != 'Z'
|
||||
offsetmins = parseInt(q[8], 10) * 60 + parseInt(q[9], 10)
|
||||
offsetmins = 0 - offsetmins if q[7] == '+'
|
||||
Date.UTC(
|
||||
parseInt(q[1], 10),
|
||||
parseInt(q[2], 10) - 1,
|
||||
parseInt(q[3], 10),
|
||||
parseInt(q[4], 10),
|
||||
parseInt(q[5], 10)).getTime()
|
||||
parseInt(q[5], 10) + offsetmins)
|
||||
else if r
|
||||
offsetmins = 0
|
||||
if r[8] != 'Z'
|
||||
offsetmins = parseInt(r[10], 10) * 60 + parseInt(r[11], 10)
|
||||
offsetmins = 0 - offsetmins if r[9] == '+'
|
||||
secs = parseFloat(r[6])
|
||||
isecs = Math.floor(secs)
|
||||
msecs = Math.round((secs - isecs) * 1000)
|
||||
new Date(
|
||||
msecs = Math.floor((secs - isecs) * 1000)
|
||||
Date.UTC(
|
||||
parseInt(r[1], 10),
|
||||
parseInt(r[2], 10) - 1,
|
||||
parseInt(r[3], 10),
|
||||
parseInt(r[4], 10),
|
||||
parseInt(r[5], 10),
|
||||
parseInt(r[5], 10) + offsetmins,
|
||||
isecs,
|
||||
msecs).getTime()
|
||||
msecs)
|
||||
else
|
||||
new Date(parseInt(date, 10), 0, 1).getTime()
|
||||
|
||||
|
22
morris.js
22
morris.js
@ -450,14 +450,14 @@
|
||||
})();
|
||||
|
||||
Morris.parseDate = function(date) {
|
||||
var isecs, m, msecs, n, o, p, q, r, ret, secs;
|
||||
var isecs, m, msecs, n, o, offsetmins, p, q, r, ret, secs;
|
||||
if (typeof date === 'number') return date;
|
||||
m = date.match(/^(\d+) Q(\d)$/);
|
||||
n = date.match(/^(\d+)-(\d+)$/);
|
||||
o = date.match(/^(\d+)-(\d+)-(\d+)$/);
|
||||
p = date.match(/^(\d+) W(\d+)$/);
|
||||
q = date.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)Z?$/);
|
||||
r = date.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)Z?$/);
|
||||
q = date.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d+):(\d+))?$/);
|
||||
r = date.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d+):(\d+))?$/);
|
||||
if (m) {
|
||||
return new Date(parseInt(m[1], 10), parseInt(m[2], 10) * 3 - 1, 1).getTime();
|
||||
} else if (n) {
|
||||
@ -469,12 +469,22 @@
|
||||
if (ret.getDay() !== 4) ret.setMonth(0, 1 + ((4 - ret.getDay()) + 7) % 7);
|
||||
return ret.getTime() + parseInt(p[2], 10) * 604800000;
|
||||
} else if (q) {
|
||||
return new Date(parseInt(q[1], 10), parseInt(q[2], 10) - 1, parseInt(q[3], 10), parseInt(q[4], 10), parseInt(q[5], 10)).getTime();
|
||||
offsetmins = 0;
|
||||
if (q[6] !== 'Z') {
|
||||
offsetmins = parseInt(q[8], 10) * 60 + parseInt(q[9], 10);
|
||||
if (q[7] === '+') offsetmins = 0 - offsetmins;
|
||||
}
|
||||
return Date.UTC(parseInt(q[1], 10), parseInt(q[2], 10) - 1, parseInt(q[3], 10), parseInt(q[4], 10), parseInt(q[5], 10) + offsetmins);
|
||||
} else if (r) {
|
||||
offsetmins = 0;
|
||||
if (r[8] !== 'Z') {
|
||||
offsetmins = parseInt(r[10], 10) * 60 + parseInt(r[11], 10);
|
||||
if (r[9] === '+') offsetmins = 0 - offsetmins;
|
||||
}
|
||||
secs = parseFloat(r[6]);
|
||||
isecs = Math.floor(secs);
|
||||
msecs = Math.round((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();
|
||||
msecs = Math.floor((secs - isecs) * 1000);
|
||||
return Date.UTC(parseInt(r[1], 10), parseInt(r[2], 10) - 1, parseInt(r[3], 10), parseInt(r[4], 10), parseInt(r[5], 10) + offsetmins, isecs, msecs);
|
||||
} else {
|
||||
return new Date(parseInt(date, 10), 0, 1).getTime();
|
||||
}
|
||||
|
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