版博士V2.0程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

29 行
511 B

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