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.
25 lines
421 B
25 lines
421 B
'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; |