HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/self/root/usr/share/nodejs/tap-yaml/lib/types/
Upload File :
Current File : //proc/self/root/usr/share/nodejs/tap-yaml/lib/types/date.js
const {stringifyString} = require('yaml/util')

module.exports = {
  tag: '!date',
  identify: value => value instanceof Date,
  resolve (doc, cst) {
    const src = cst.strValue
    const match = src.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)$/)
    if (!match)
      throw new Error(`Invalid date string: ${src}`)
    return new Date(src)
  },
  stringify (item, ctx, onComment, onChompKeep) {
    const value = item.value.toISOString()
    return stringifyString({ value }, ctx, onComment, onChompKeep)
  }
}