vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

656 lines
22 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. var moment = require('../module/moment');
  2. var DateUtil = require('./DateUtil');
  3. var util = require('../util');
  4. /**
  5. * @constructor TimeStep
  6. * The class TimeStep is an iterator for dates. You provide a start date and an
  7. * end date. The class itself determines the best scale (step size) based on the
  8. * provided start Date, end Date, and minimumStep.
  9. *
  10. * If minimumStep is provided, the step size is chosen as close as possible
  11. * to the minimumStep but larger than minimumStep. If minimumStep is not
  12. * provided, the scale is set to 1 DAY.
  13. * The minimumStep should correspond with the onscreen size of about 6 characters
  14. *
  15. * Alternatively, you can set a scale by hand.
  16. * After creation, you can initialize the class by executing first(). Then you
  17. * can iterate from the start date to the end date via next(). You can check if
  18. * the end date is reached with the function hasNext(). After each step, you can
  19. * retrieve the current date via getCurrent().
  20. * The TimeStep has scales ranging from milliseconds, seconds, minutes, hours,
  21. * days, to years.
  22. *
  23. * Version: 1.2
  24. *
  25. * @param {Date} [start] The start date, for example new Date(2010, 9, 21)
  26. * or new Date(2010, 9, 21, 23, 45, 00)
  27. * @param {Date} [end] The end date
  28. * @param {Number} [minimumStep] Optional. Minimum step size in milliseconds
  29. */
  30. function TimeStep(start, end, minimumStep, hiddenDates) {
  31. this.moment = moment;
  32. // variables
  33. this.current = this.moment();
  34. this._start = this.moment();
  35. this._end = this.moment();
  36. this.autoScale = true;
  37. this.scale = 'day';
  38. this.step = 1;
  39. // initialize the range
  40. this.setRange(start, end, minimumStep);
  41. // hidden Dates options
  42. this.switchedDay = false;
  43. this.switchedMonth = false;
  44. this.switchedYear = false;
  45. if (Array.isArray(hiddenDates)) {
  46. this.hiddenDates = hiddenDates;
  47. }
  48. else if (hiddenDates != undefined) {
  49. this.hiddenDates = [hiddenDates];
  50. }
  51. else {
  52. this.hiddenDates = [];
  53. }
  54. this.format = TimeStep.FORMAT; // default formatting
  55. }
  56. // Time formatting
  57. TimeStep.FORMAT = {
  58. minorLabels: {
  59. millisecond:'SSS',
  60. second: 's',
  61. minute: 'HH:mm',
  62. hour: 'HH:mm',
  63. weekday: 'ddd D',
  64. day: 'D',
  65. month: 'MMM',
  66. year: 'YYYY'
  67. },
  68. majorLabels: {
  69. millisecond:'HH:mm:ss',
  70. second: 'D MMMM HH:mm',
  71. minute: 'ddd D MMMM',
  72. hour: 'ddd D MMMM',
  73. weekday: 'MMMM YYYY',
  74. day: 'MMMM YYYY',
  75. month: 'YYYY',
  76. year: ''
  77. }
  78. };
  79. /**
  80. * Set custom constructor function for moment. Can be used to set dates
  81. * to UTC or to set a utcOffset.
  82. * @param {function} moment
  83. */
  84. TimeStep.prototype.setMoment = function (moment) {
  85. this.moment = moment;
  86. // update the date properties, can have a new utcOffset
  87. this.current = this.moment(this.current.valueOf());
  88. this._start = this.moment(this._start.valueOf());
  89. this._end = this.moment(this._end.valueOf());
  90. };
  91. /**
  92. * Set custom formatting for the minor an major labels of the TimeStep.
  93. * Both `minorLabels` and `majorLabels` are an Object with properties:
  94. * 'millisecond', 'second', 'minute', 'hour', 'weekday', 'day', 'month', 'year'.
  95. * @param {{minorLabels: Object, majorLabels: Object}} format
  96. */
  97. TimeStep.prototype.setFormat = function (format) {
  98. var defaultFormat = util.deepExtend({}, TimeStep.FORMAT);
  99. this.format = util.deepExtend(defaultFormat, format);
  100. };
  101. /**
  102. * Set a new range
  103. * If minimumStep is provided, the step size is chosen as close as possible
  104. * to the minimumStep but larger than minimumStep. If minimumStep is not
  105. * provided, the scale is set to 1 DAY.
  106. * The minimumStep should correspond with the onscreen size of about 6 characters
  107. * @param {Date} [start] The start date and time.
  108. * @param {Date} [end] The end date and time.
  109. * @param {int} [minimumStep] Optional. Minimum step size in milliseconds
  110. */
  111. TimeStep.prototype.setRange = function(start, end, minimumStep) {
  112. if (!(start instanceof Date) || !(end instanceof Date)) {
  113. throw "No legal start or end date in method setRange";
  114. }
  115. this._start = (start != undefined) ? this.moment(start.valueOf()) : new Date();
  116. this._end = (end != undefined) ? this.moment(end.valueOf()) : new Date();
  117. if (this.autoScale) {
  118. this.setMinimumStep(minimumStep);
  119. }
  120. };
  121. /**
  122. * Set the range iterator to the start date.
  123. */
  124. TimeStep.prototype.start = function() {
  125. this.current = this._start.clone();
  126. this.roundToMinor();
  127. };
  128. /**
  129. * Round the current date to the first minor date value
  130. * This must be executed once when the current date is set to start Date
  131. */
  132. TimeStep.prototype.roundToMinor = function() {
  133. // round to floor
  134. // IMPORTANT: we have no breaks in this switch! (this is no bug)
  135. // noinspection FallThroughInSwitchStatementJS
  136. switch (this.scale) {
  137. case 'year':
  138. this.current.year(this.step * Math.floor(this.current.year() / this.step));
  139. this.current.month(0);
  140. case 'month': this.current.date(1);
  141. case 'day': // intentional fall through
  142. case 'weekday': this.current.hours(0);
  143. case 'hour': this.current.minutes(0);
  144. case 'minute': this.current.seconds(0);
  145. case 'second': this.current.milliseconds(0);
  146. //case 'millisecond': // nothing to do for milliseconds
  147. }
  148. if (this.step != 1) {
  149. // round down to the first minor value that is a multiple of the current step size
  150. switch (this.scale) {
  151. case 'millisecond': this.current.subtract(this.current.milliseconds() % this.step, 'milliseconds'); break;
  152. case 'second': this.current.subtract(this.current.seconds() % this.step, 'seconds'); break;
  153. case 'minute': this.current.subtract(this.current.minutes() % this.step, 'minutes'); break;
  154. case 'hour': this.current.subtract(this.current.hours() % this.step, 'hours'); break;
  155. case 'weekday': // intentional fall through
  156. case 'day': this.current.subtract((this.current.date() - 1) % this.step, 'day'); break;
  157. case 'month': this.current.subtract(this.current.month() % this.step, 'month'); break;
  158. case 'year': this.current.subtract(this.current.year() % this.step, 'year'); break;
  159. default: break;
  160. }
  161. }
  162. };
  163. /**
  164. * Check if the there is a next step
  165. * @return {boolean} true if the current date has not passed the end date
  166. */
  167. TimeStep.prototype.hasNext = function () {
  168. return (this.current.valueOf() <= this._end.valueOf());
  169. };
  170. /**
  171. * Do the next step
  172. */
  173. TimeStep.prototype.next = function() {
  174. var prev = this.current.valueOf();
  175. // Two cases, needed to prevent issues with switching daylight savings
  176. // (end of March and end of October)
  177. if (this.current.month() < 6) {
  178. switch (this.scale) {
  179. case 'millisecond': this.current.add(this.step, 'millisecond'); break;
  180. case 'second': this.current.add(this.step, 'second'); break;
  181. case 'minute': this.current.add(this.step, 'minute'); break;
  182. case 'hour':
  183. this.current.add(this.step, 'hour');
  184. // in case of skipping an hour for daylight savings, adjust the hour again (else you get: 0h 5h 9h ... instead of 0h 4h 8h ...)
  185. // TODO: is this still needed now we use the function of moment.js?
  186. this.current.subtract(this.current.hours() % this.step, 'hour');
  187. break;
  188. case 'weekday': // intentional fall through
  189. case 'day': this.current.add(this.step, 'day'); break;
  190. case 'month': this.current.add(this.step, 'month'); break;
  191. case 'year': this.current.add(this.step, 'year'); break;
  192. default: break;
  193. }
  194. }
  195. else {
  196. switch (this.scale) {
  197. case 'millisecond': this.current.add(this.step, 'millisecond'); break;
  198. case 'second': this.current.add(this.step, 'second'); break;
  199. case 'minute': this.current.add(this.step, 'minute'); break;
  200. case 'hour':
  201. this.current.add(this.moment.duration(this.step, 'hour'));
  202. // correct for daylight saving
  203. // FIXME: use this.current.add(moment.duration(this.step, 'hour'))
  204. // see http://momentjs.com/docs/#special-considerations-for-months-and-years
  205. if (this.current.hours() % this.step !== 0) {
  206. this.current.add(this.step - this.current.hours() % this.step, 'hour');
  207. }
  208. break;
  209. case 'weekday': // intentional fall through
  210. case 'day': this.current.add(this.step, 'day'); break;
  211. case 'month': this.current.add(this.step, 'month'); break;
  212. case 'year': this.current.add(this.step, 'year'); break;
  213. default: break;
  214. }
  215. }
  216. if (this.step != 1) {
  217. // round down to the correct major value
  218. switch (this.scale) {
  219. case 'millisecond': if(this.current.milliseconds() > 0 && this.current.milliseconds() < this.step) this.current.milliseconds(0); break;
  220. case 'second': if(this.current.seconds() > 0 && this.current.seconds() < this.step) this.current.seconds(0); break;
  221. case 'minute': if(this.current.minutes() > 0 && this.current.minutes() < this.step) this.current.minutes(0); break;
  222. case 'hour': if(this.current.hours() > 0 && this.current.hours() < this.step) this.current.hours(0); break;
  223. case 'weekday': // intentional fall through
  224. case 'day': if(this.current.date() < this.step+1) this.current.date(1); break;
  225. case 'month': if(this.current.month() < this.step) this.current.month(0); break;
  226. case 'year': break; // nothing to do for year
  227. default: break;
  228. }
  229. }
  230. // safety mechanism: if current time is still unchanged, move to the end
  231. if (this.current.valueOf() == prev) {
  232. this.current = this._end.clone();
  233. }
  234. // Reset switches for year, month and day. Will get set to true where appropriate in DateUtil.stepOverHiddenDates
  235. this.switchedDay = false;
  236. this.switchedMonth = false;
  237. this.switchedYear = false;
  238. DateUtil.stepOverHiddenDates(this.moment, this, prev);
  239. };
  240. /**
  241. * Get the current datetime
  242. * @return {Moment} current The current date
  243. */
  244. TimeStep.prototype.getCurrent = function() {
  245. return this.current;
  246. };
  247. /**
  248. * Set a custom scale. Autoscaling will be disabled.
  249. * For example setScale('minute', 5) will result
  250. * in minor steps of 5 minutes, and major steps of an hour.
  251. *
  252. * @param {{scale: string, step: number}} params
  253. * An object containing two properties:
  254. * - A string 'scale'. Choose from 'millisecond', 'second',
  255. * 'minute', 'hour', 'weekday', 'day', 'month', 'year'.
  256. * - A number 'step'. A step size, by default 1.
  257. * Choose for example 1, 2, 5, or 10.
  258. */
  259. TimeStep.prototype.setScale = function(params) {
  260. if (params && typeof params.scale == 'string') {
  261. this.scale = params.scale;
  262. this.step = params.step > 0 ? params.step : 1;
  263. this.autoScale = false;
  264. }
  265. };
  266. /**
  267. * Enable or disable autoscaling
  268. * @param {boolean} enable If true, autoascaling is set true
  269. */
  270. TimeStep.prototype.setAutoScale = function (enable) {
  271. this.autoScale = enable;
  272. };
  273. /**
  274. * Automatically determine the scale that bests fits the provided minimum step
  275. * @param {Number} [minimumStep] The minimum step size in milliseconds
  276. */
  277. TimeStep.prototype.setMinimumStep = function(minimumStep) {
  278. if (minimumStep == undefined) {
  279. return;
  280. }
  281. //var b = asc + ds;
  282. var stepYear = (1000 * 60 * 60 * 24 * 30 * 12);
  283. var stepMonth = (1000 * 60 * 60 * 24 * 30);
  284. var stepDay = (1000 * 60 * 60 * 24);
  285. var stepHour = (1000 * 60 * 60);
  286. var stepMinute = (1000 * 60);
  287. var stepSecond = (1000);
  288. var stepMillisecond= (1);
  289. // find the smallest step that is larger than the provided minimumStep
  290. if (stepYear*1000 > minimumStep) {this.scale = 'year'; this.step = 1000;}
  291. if (stepYear*500 > minimumStep) {this.scale = 'year'; this.step = 500;}
  292. if (stepYear*100 > minimumStep) {this.scale = 'year'; this.step = 100;}
  293. if (stepYear*50 > minimumStep) {this.scale = 'year'; this.step = 50;}
  294. if (stepYear*10 > minimumStep) {this.scale = 'year'; this.step = 10;}
  295. if (stepYear*5 > minimumStep) {this.scale = 'year'; this.step = 5;}
  296. if (stepYear > minimumStep) {this.scale = 'year'; this.step = 1;}
  297. if (stepMonth*3 > minimumStep) {this.scale = 'month'; this.step = 3;}
  298. if (stepMonth > minimumStep) {this.scale = 'month'; this.step = 1;}
  299. if (stepDay*5 > minimumStep) {this.scale = 'day'; this.step = 5;}
  300. if (stepDay*2 > minimumStep) {this.scale = 'day'; this.step = 2;}
  301. if (stepDay > minimumStep) {this.scale = 'day'; this.step = 1;}
  302. if (stepDay/2 > minimumStep) {this.scale = 'weekday'; this.step = 1;}
  303. if (stepHour*4 > minimumStep) {this.scale = 'hour'; this.step = 4;}
  304. if (stepHour > minimumStep) {this.scale = 'hour'; this.step = 1;}
  305. if (stepMinute*15 > minimumStep) {this.scale = 'minute'; this.step = 15;}
  306. if (stepMinute*10 > minimumStep) {this.scale = 'minute'; this.step = 10;}
  307. if (stepMinute*5 > minimumStep) {this.scale = 'minute'; this.step = 5;}
  308. if (stepMinute > minimumStep) {this.scale = 'minute'; this.step = 1;}
  309. if (stepSecond*15 > minimumStep) {this.scale = 'second'; this.step = 15;}
  310. if (stepSecond*10 > minimumStep) {this.scale = 'second'; this.step = 10;}
  311. if (stepSecond*5 > minimumStep) {this.scale = 'second'; this.step = 5;}
  312. if (stepSecond > minimumStep) {this.scale = 'second'; this.step = 1;}
  313. if (stepMillisecond*200 > minimumStep) {this.scale = 'millisecond'; this.step = 200;}
  314. if (stepMillisecond*100 > minimumStep) {this.scale = 'millisecond'; this.step = 100;}
  315. if (stepMillisecond*50 > minimumStep) {this.scale = 'millisecond'; this.step = 50;}
  316. if (stepMillisecond*10 > minimumStep) {this.scale = 'millisecond'; this.step = 10;}
  317. if (stepMillisecond*5 > minimumStep) {this.scale = 'millisecond'; this.step = 5;}
  318. if (stepMillisecond > minimumStep) {this.scale = 'millisecond'; this.step = 1;}
  319. };
  320. /**
  321. * Snap a date to a rounded value.
  322. * The snap intervals are dependent on the current scale and step.
  323. * Static function
  324. * @param {Date} date the date to be snapped.
  325. * @param {string} scale Current scale, can be 'millisecond', 'second',
  326. * 'minute', 'hour', 'weekday, 'day', 'month', 'year'.
  327. * @param {number} step Current step (1, 2, 4, 5, ...
  328. * @return {Date} snappedDate
  329. */
  330. TimeStep.snap = function(date, scale, step) {
  331. var clone = moment(date);
  332. if (scale == 'year') {
  333. var year = clone.year() + Math.round(clone.month() / 12);
  334. clone.year(Math.round(year / step) * step);
  335. clone.month(0);
  336. clone.date(0);
  337. clone.hours(0);
  338. clone.minutes(0);
  339. clone.seconds(0);
  340. clone.milliseconds(0);
  341. }
  342. else if (scale == 'month') {
  343. if (clone.date() > 15) {
  344. clone.date(1);
  345. clone.add(1, 'month');
  346. // important: first set Date to 1, after that change the month.
  347. }
  348. else {
  349. clone.date(1);
  350. }
  351. clone.hours(0);
  352. clone.minutes(0);
  353. clone.seconds(0);
  354. clone.milliseconds(0);
  355. }
  356. else if (scale == 'day') {
  357. //noinspection FallthroughInSwitchStatementJS
  358. switch (step) {
  359. case 5:
  360. case 2:
  361. clone.hours(Math.round(clone.hours() / 24) * 24); break;
  362. default:
  363. clone.hours(Math.round(clone.hours() / 12) * 12); break;
  364. }
  365. clone.minutes(0);
  366. clone.seconds(0);
  367. clone.milliseconds(0);
  368. }
  369. else if (scale == 'weekday') {
  370. //noinspection FallthroughInSwitchStatementJS
  371. switch (step) {
  372. case 5:
  373. case 2:
  374. clone.hours(Math.round(clone.hours() / 12) * 12); break;
  375. default:
  376. clone.hours(Math.round(clone.hours() / 6) * 6); break;
  377. }
  378. clone.minutes(0);
  379. clone.seconds(0);
  380. clone.milliseconds(0);
  381. }
  382. else if (scale == 'hour') {
  383. switch (step) {
  384. case 4:
  385. clone.minutes(Math.round(clone.minutes() / 60) * 60); break;
  386. default:
  387. clone.minutes(Math.round(clone.minutes() / 30) * 30); break;
  388. }
  389. clone.seconds(0);
  390. clone.milliseconds(0);
  391. } else if (scale == 'minute') {
  392. //noinspection FallthroughInSwitchStatementJS
  393. switch (step) {
  394. case 15:
  395. case 10:
  396. clone.minutes(Math.round(clone.minutes() / 5) * 5);
  397. clone.seconds(0);
  398. break;
  399. case 5:
  400. clone.seconds(Math.round(clone.seconds() / 60) * 60); break;
  401. default:
  402. clone.seconds(Math.round(clone.seconds() / 30) * 30); break;
  403. }
  404. clone.milliseconds(0);
  405. }
  406. else if (scale == 'second') {
  407. //noinspection FallthroughInSwitchStatementJS
  408. switch (step) {
  409. case 15:
  410. case 10:
  411. clone.seconds(Math.round(clone.seconds() / 5) * 5);
  412. clone.milliseconds(0);
  413. break;
  414. case 5:
  415. clone.milliseconds(Math.round(clone.milliseconds() / 1000) * 1000); break;
  416. default:
  417. clone.milliseconds(Math.round(clone.milliseconds() / 500) * 500); break;
  418. }
  419. }
  420. else if (scale == 'millisecond') {
  421. var _step = step > 5 ? step / 2 : 1;
  422. clone.milliseconds(Math.round(clone.milliseconds() / _step) * _step);
  423. }
  424. return clone;
  425. };
  426. /**
  427. * Check if the current value is a major value (for example when the step
  428. * is DAY, a major value is each first day of the MONTH)
  429. * @return {boolean} true if current date is major, else false.
  430. */
  431. TimeStep.prototype.isMajor = function() {
  432. if (this.switchedYear == true) {
  433. switch (this.scale) {
  434. case 'year':
  435. case 'month':
  436. case 'weekday':
  437. case 'day':
  438. case 'hour':
  439. case 'minute':
  440. case 'second':
  441. case 'millisecond':
  442. return true;
  443. default:
  444. return false;
  445. }
  446. }
  447. else if (this.switchedMonth == true) {
  448. switch (this.scale) {
  449. case 'weekday':
  450. case 'day':
  451. case 'hour':
  452. case 'minute':
  453. case 'second':
  454. case 'millisecond':
  455. return true;
  456. default:
  457. return false;
  458. }
  459. }
  460. else if (this.switchedDay == true) {
  461. switch (this.scale) {
  462. case 'millisecond':
  463. case 'second':
  464. case 'minute':
  465. case 'hour':
  466. return true;
  467. default:
  468. return false;
  469. }
  470. }
  471. var date = this.moment(this.current);
  472. switch (this.scale) {
  473. case 'millisecond':
  474. return (date.milliseconds() == 0);
  475. case 'second':
  476. return (date.seconds() == 0);
  477. case 'minute':
  478. return (date.hours() == 0) && (date.minutes() == 0);
  479. case 'hour':
  480. return (date.hours() == 0);
  481. case 'weekday': // intentional fall through
  482. case 'day':
  483. return (date.date() == 1);
  484. case 'month':
  485. return (date.month() == 0);
  486. case 'year':
  487. return false;
  488. default:
  489. return false;
  490. }
  491. };
  492. /**
  493. * Returns formatted text for the minor axislabel, depending on the current
  494. * date and the scale. For example when scale is MINUTE, the current time is
  495. * formatted as "hh:mm".
  496. * @param {Date} [date] custom date. if not provided, current date is taken
  497. */
  498. TimeStep.prototype.getLabelMinor = function(date) {
  499. if (date == undefined) {
  500. date = this.current;
  501. }
  502. if (typeof(this.format.minorLabels) === "function") {
  503. return this.format.minorLabels(date, this.scale, this.step);
  504. }
  505. var format = this.format.minorLabels[this.scale];
  506. return (format && format.length > 0) ? this.moment(date).format(format) : '';
  507. };
  508. /**
  509. * Returns formatted text for the major axis label, depending on the current
  510. * date and the scale. For example when scale is MINUTE, the major scale is
  511. * hours, and the hour will be formatted as "hh".
  512. * @param {Date} [date] custom date. if not provided, current date is taken
  513. */
  514. TimeStep.prototype.getLabelMajor = function(date) {
  515. if (date == undefined) {
  516. date = this.current;
  517. }
  518. if (typeof(this.format.majorLabels) === "function") {
  519. return this.format.majorLabels(date, this.scale, this.step);
  520. }
  521. var format = this.format.majorLabels[this.scale];
  522. return (format && format.length > 0) ? this.moment(date).format(format) : '';
  523. };
  524. TimeStep.prototype.getClassName = function() {
  525. var _moment = this.moment;
  526. var m = this.moment(this.current);
  527. var current = m.locale ? m.locale('en') : m.lang('en'); // old versions of moment have .lang() function
  528. var step = this.step;
  529. function even(value) {
  530. return (value / step % 2 == 0) ? ' vis-even' : ' vis-odd';
  531. }
  532. function today(date) {
  533. if (date.isSame(new Date(), 'day')) {
  534. return ' vis-today';
  535. }
  536. if (date.isSame(_moment().add(1, 'day'), 'day')) {
  537. return ' vis-tomorrow';
  538. }
  539. if (date.isSame(_moment().add(-1, 'day'), 'day')) {
  540. return ' vis-yesterday';
  541. }
  542. return '';
  543. }
  544. function currentWeek(date) {
  545. return date.isSame(new Date(), 'week') ? ' vis-current-week' : '';
  546. }
  547. function currentMonth(date) {
  548. return date.isSame(new Date(), 'month') ? ' vis-current-month' : '';
  549. }
  550. function currentYear(date) {
  551. return date.isSame(new Date(), 'year') ? ' vis-current-year' : '';
  552. }
  553. switch (this.scale) {
  554. case 'millisecond':
  555. return today(current) +
  556. even(current.milliseconds()).trim();
  557. case 'second':
  558. return today(current) +
  559. even(current.seconds()).trim();
  560. case 'minute':
  561. return today(current) +
  562. even(current.minutes()).trim();
  563. case 'hour':
  564. return 'vis-h' + current.hours() +
  565. (this.step == 4 ? '-h' + (current.hours() + 4) : '') +
  566. today(current) +
  567. even(current.hours());
  568. case 'weekday':
  569. return 'vis-' + current.format('dddd').toLowerCase() +
  570. today(current) +
  571. currentWeek(current) +
  572. even(current.date());
  573. case 'day':
  574. return 'vis-day' + current.date() +
  575. ' vis-' + current.format('MMMM').toLowerCase() +
  576. today(current) +
  577. currentMonth(current) +
  578. (this.step <= 2 ? today(current) : '') +
  579. (this.step <= 2 ? ' vis-' + current.format('dddd').toLowerCase() : '' + even(current.date() - 1));
  580. case 'month':
  581. return 'vis-' + current.format('MMMM').toLowerCase() +
  582. currentMonth(current) +
  583. even(current.month());
  584. case 'year':
  585. var year = current.year();
  586. return 'vis-year' + year +
  587. currentYear(current) +
  588. even(year);
  589. default:
  590. return '';
  591. }
  592. };
  593. module.exports = TimeStep;