|
598 | 598 | var idF = axis.fTimeFormat.indexOf('%F'); |
599 | 599 | if (idF < 0) return JSROOT.gStyle.TimeOffset; |
600 | 600 | var sof = axis.fTimeFormat.substr(idF + 2); |
601 | | - if (sof == '1995-01-01 00:00:00s0') return 788918400000; |
| 601 | + // default string in axis offset |
| 602 | + if (sof.indexOf('1995-01-01 00:00:00s0')==0) return 788918400000; |
602 | 603 | // special case, used from DABC painters |
603 | 604 | if ((sof == "0") || (sof == "")) return 0; |
604 | 605 |
|
605 | 606 | // decode time from ROOT string |
606 | | - var dt = new Date(0); |
607 | | - var pos = sof.indexOf("-"); dt.setFullYear(sof.substr(0,pos)); sof = sof.substr(pos+1); |
608 | | - pos = sof.indexOf("-"); dt.setMonth(parseInt(sof.substr(0,pos))-1); sof = sof.substr(pos+1); |
609 | | - pos = sof.indexOf(" "); dt.setDate(sof.substr(0,pos)); sof = sof.substr(pos+1); |
610 | | - pos = sof.indexOf(":"); dt.setHours(sof.substr(0,pos)); sof = sof.substr(pos+1); |
611 | | - pos = sof.indexOf(":"); dt.setMinutes(sof.substr(0,pos)); sof = sof.substr(pos+1); |
612 | | - pos = sof.indexOf("s"); dt.setSeconds(sof.substr(0,pos)); |
613 | | - if (pos>0) { sof = sof.substr(pos+1); dt.setMilliseconds(sof); } |
| 607 | + function next(separ, min, max) { |
| 608 | + var pos = sof.indexOf(separ); |
| 609 | + if (pos < 0) { pos = ""; return min; } |
| 610 | + var val = parseInt(sof.substr(0,pos)); |
| 611 | + sof = sof.substr(pos+1); |
| 612 | + if (isNaN(val) || (val<min) || (val>max)) { pos = ""; return min; } |
| 613 | + return val; |
| 614 | + } |
| 615 | + |
| 616 | + var year = next("-", 1970, 2300), |
| 617 | + month = next("-", 1, 12) - 1, |
| 618 | + day = next(" ", 1, 31), |
| 619 | + hour = next(":", 0, 23), |
| 620 | + min = next(":", 0, 59), |
| 621 | + sec = next("s", 0, 59), |
| 622 | + msec = next(" ", 0, 999); |
| 623 | + |
| 624 | + var dt = new Date(Date.UTC(year, month, day, hour, min, sec, msec)); |
614 | 625 | return dt.getTime(); |
615 | 626 | } |
616 | 627 |
|
|
0 commit comments