setup-python/node_modules/prompts/lib/dateparts/meridiem.js
Danny McCormick 39c08a0eaa Initial pass
2019-06-26 21:12:00 -04:00

24 lines
419 B
JavaScript

'use strict';
const DatePart = require('./datepart');
class Meridiem extends DatePart {
constructor(opts={}) {
super(opts);
}
up() {
this.date.setHours((this.date.getHours() + 12) % 24);
}
down() {
this.up();
}
toString() {
let meridiem = this.date.getHours() > 12 ? 'pm' : 'am';
return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem;
}
}
module.exports = Meridiem;