frontend/.pnpm-store/v3/files/ad/d77b0a1bf54e0da69677087399cd10550eee1b1004276fd657c6b298107cbdc482119a8fde9508e9ad23212b4d5bfbff1a4998fddb2c8a62e08c72afc337c1-exec

24 lines
485 B
Plaintext
Executable File

'use strict'
const f = require('./format-num.js')
const DateTime = global.Date
class Date extends DateTime {
constructor (value) {
super(value)
this.isDate = true
}
toISOString () {
return `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`
}
}
module.exports = value => {
const date = new Date(value)
/* istanbul ignore if */
if (isNaN(date)) {
throw new TypeError('Invalid Datetime')
} else {
return date
}
}