date.js 462 B

1234567891011121314
  1. import { truncate } from './helpers'
  2. export default function inspectDate(dateObject, options) {
  3. const stringRepresentation = dateObject.toJSON()
  4. if (stringRepresentation === null) {
  5. return 'Invalid Date'
  6. }
  7. const split = stringRepresentation.split('T')
  8. const date = split[0]
  9. // If we need to - truncate the time portion, but never the date
  10. return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, 'date')
  11. }