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.
15 lines
462 B
15 lines
462 B
2 years ago
|
import { truncate } from './helpers'
|
||
|
|
||
|
export default function inspectDate(dateObject, options) {
|
||
|
const stringRepresentation = dateObject.toJSON()
|
||
|
|
||
|
if (stringRepresentation === null) {
|
||
|
return 'Invalid Date'
|
||
|
}
|
||
|
|
||
|
const split = stringRepresentation.split('T')
|
||
|
const date = split[0]
|
||
|
// If we need to - truncate the time portion, but never the date
|
||
|
return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, 'date')
|
||
|
}
|