minutes.js 497 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const DatePart = require('./datepart');
  3. class Minutes extends DatePart {
  4. constructor(opts={}) {
  5. super(opts);
  6. }
  7. up() {
  8. this.date.setMinutes(this.date.getMinutes() + 1);
  9. }
  10. down() {
  11. this.date.setMinutes(this.date.getMinutes() - 1);
  12. }
  13. setTo(val) {
  14. this.date.setMinutes(parseInt(val.substr(-2)));
  15. }
  16. toString() {
  17. let m = this.date.getMinutes();
  18. return this.token.length > 1 ? String(m).padStart(2, '0') : m;
  19. }
  20. }
  21. module.exports = Minutes;