版博士V2.0程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

30 lignes
551 B

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