Urara-Blog/node_modules/.pnpm-store/v3/files/b2/315118e786b3a78c186d2fad3f0fd246d27b5e2412a72c38e553a7ca491c782bac19d79cbad92b4a08d6e1a58bdc898464bc955d71a68d2a241cd79f705e70-exec
2022-08-14 01:14:53 +08:00

22 lines
508 B
Text
Executable file

'use strict'
const f = require('./format-num.js')
class Time extends Date {
constructor (value) {
super(`0000-01-01T${value}Z`)
this.isTime = true
}
toISOString () {
return `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`
}
}
module.exports = value => {
const date = new Time(value)
/* istanbul ignore if */
if (isNaN(date)) {
throw new TypeError('Invalid Datetime')
} else {
return date
}
}