|
6289 | 6289 | }; |
6290 | 6290 | } |
6291 | 6291 | d3.time = {}; |
6292 | | - var d3_time = Date, d3_time_weekdaySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; |
| 6292 | + var d3_time = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; |
6293 | 6293 | function d3_time_utc() { |
6294 | 6294 | this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); |
6295 | 6295 | } |
|
6357 | 6357 | }; |
6358 | 6358 | var d3_time_prototype = Date.prototype; |
6359 | 6359 | var d3_time_formatDateTime = "%a %b %e %H:%M:%S %Y", d3_time_formatDate = "%m/%d/%y", d3_time_formatTime = "%H:%M:%S"; |
6360 | | - var d3_time_weekdays = d3_time_weekdaySymbols, d3_time_months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; |
| 6360 | + var d3_time_days = d3_time_daySymbols, d3_time_dayAbbreviations = d3_time_days.map(d3_time_formatAbbreviate), d3_time_months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], d3_time_monthAbbreviations = d3_time_months.map(d3_time_formatAbbreviate); |
| 6361 | + function d3_time_formatAbbreviate(name) { |
| 6362 | + return name.substring(0, 3); |
| 6363 | + } |
6361 | 6364 | d3.time.format = function(template) { |
6362 | 6365 | var n = template.length; |
6363 | 6366 | function format(date) { |
|
6407 | 6410 | } |
6408 | 6411 | return j; |
6409 | 6412 | } |
6410 | | - function d3_time_formatAbbrev(s) { |
6411 | | - return s.substring(0, 3); |
6412 | | - } |
6413 | 6413 | function d3_time_formatRe(names) { |
6414 | 6414 | return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); |
6415 | 6415 | } |
|
6419 | 6419 | return map; |
6420 | 6420 | } |
6421 | 6421 | var d3_time_zfill2 = d3.format("02d"), d3_time_zfill3 = d3.format("03d"), d3_time_zfill4 = d3.format("04d"), d3_time_sfill2 = d3.format("2d"); |
6422 | | - var d3_time_weekdayRe = d3_time_formatRe(d3_time_weekdays), d3_time_weekdayAbbrevRe = d3_time_formatRe(d3_time_weekdays.map(d3_time_formatAbbrev)), d3_time_monthRe = d3_time_formatRe(d3_time_months), d3_time_monthLookup = d3_time_formatLookup(d3_time_months), d3_time_monthAbbrevLookup = d3_time_formatLookup(d3_time_months.map(d3_time_formatAbbrev)); |
| 6422 | + var d3_time_dayRe = d3_time_formatRe(d3_time_days), d3_time_dayAbbrevRe = d3_time_formatRe(d3_time_dayAbbreviations), d3_time_monthRe = d3_time_formatRe(d3_time_months), d3_time_monthLookup = d3_time_formatLookup(d3_time_months), d3_time_monthAbbrevRe = d3_time_formatRe(d3_time_monthAbbreviations), d3_time_monthAbbrevLookup = d3_time_formatLookup(d3_time_monthAbbreviations); |
6423 | 6423 | var d3_time_formats = { |
6424 | 6424 | a: function(d) { |
6425 | | - return d3_time_weekdays[d.getDay()].substring(0, 3); |
| 6425 | + return d3_time_dayAbbreviations[d.getDay()]; |
6426 | 6426 | }, |
6427 | 6427 | A: function(d) { |
6428 | | - return d3_time_weekdays[d.getDay()]; |
| 6428 | + return d3_time_days[d.getDay()]; |
6429 | 6429 | }, |
6430 | 6430 | b: function(d) { |
6431 | | - return d3_time_months[d.getMonth()].substring(0, 3); |
| 6431 | + return d3_time_monthAbbreviations[d.getMonth()]; |
6432 | 6432 | }, |
6433 | 6433 | B: function(d) { |
6434 | 6434 | return d3_time_months[d.getMonth()]; |
|
6507 | 6507 | Y: d3_time_parseFullYear |
6508 | 6508 | }; |
6509 | 6509 | function d3_time_parseWeekdayAbbrev(date, string, i) { |
6510 | | - return d3_time_weekdayAbbrevRe.test(string.substring(i, i += 3)) ? i : -1; |
| 6510 | + d3_time_dayAbbrevRe.lastIndex = 0; |
| 6511 | + var n = d3_time_dayAbbrevRe.exec(string.substring(i)); |
| 6512 | + return n ? i += n[0].length : -1; |
6511 | 6513 | } |
6512 | 6514 | function d3_time_parseWeekday(date, string, i) { |
6513 | | - d3_time_weekdayRe.lastIndex = 0; |
6514 | | - var n = d3_time_weekdayRe.exec(string.substring(i, i + 10)); |
| 6515 | + d3_time_dayRe.lastIndex = 0; |
| 6516 | + var n = d3_time_dayRe.exec(string.substring(i)); |
6515 | 6517 | return n ? i += n[0].length : -1; |
6516 | 6518 | } |
6517 | 6519 | function d3_time_parseMonthAbbrev(date, string, i) { |
6518 | | - var n = d3_time_monthAbbrevLookup.get(string.substring(i, i += 3).toLowerCase()); |
6519 | | - return n == null ? -1 : (date.m = n, i); |
| 6520 | + d3_time_monthAbbrevRe.lastIndex = 0; |
| 6521 | + var n = d3_time_monthAbbrevRe.exec(string.substring(i)); |
| 6522 | + return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i += n[0].length) : -1; |
6520 | 6523 | } |
6521 | 6524 | function d3_time_parseMonth(date, string, i) { |
6522 | 6525 | d3_time_monthRe.lastIndex = 0; |
6523 | | - var n = d3_time_monthRe.exec(string.substring(i, i + 12)); |
| 6526 | + var n = d3_time_monthRe.exec(string.substring(i)); |
6524 | 6527 | return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i += n[0].length) : -1; |
6525 | 6528 | } |
6526 | 6529 | function d3_time_parseLocaleFull(date, string, i) { |
|
6575 | 6578 | var n = d3_time_numberRe.exec(string.substring(i, i + 3)); |
6576 | 6579 | return n ? (date.L = +n[0], i += n[0].length) : -1; |
6577 | 6580 | } |
6578 | | - var d3_time_numberRe = /\s*\d+/; |
| 6581 | + var d3_time_numberRe = /^\s*\d+/; |
6579 | 6582 | function d3_time_parseAmPm(date, string, i) { |
6580 | 6583 | var n = d3_time_amPmLookup.get(string.substring(i, i += 2).toLowerCase()); |
6581 | 6584 | return n == null ? -1 : (date.p = n, i); |
|
6725 | 6728 | var year = d3.time.year(date); |
6726 | 6729 | return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); |
6727 | 6730 | }; |
6728 | | - d3_time_weekdaySymbols.forEach(function(day, i) { |
| 6731 | + d3_time_daySymbols.forEach(function(day, i) { |
6729 | 6732 | day = day.toLowerCase(); |
6730 | 6733 | i = 7 - i; |
6731 | 6734 | var interval = d3.time[day] = d3_time_interval(function(date) { |
|
0 commit comments