data-api-suite icon indicating copy to clipboard operation
data-api-suite copied to clipboard

Bug in FormatISO9075

Open snorberhuis opened this issue 3 years ago • 1 comments

There is a bug in formatISO9075 in retrieving the date. It retrieves the day of the week instead. See this fix:


export const formatISO9075 = (date: Date): string => {
    const y = date.getUTCFullYear().toString()
    const m = (date.getUTCMonth() + 1).toString().padStart(2, '0')
    const d = date.getUTCDate().toString().padStart(2, '0')
    const h = date.getUTCHours().toString().padStart(2, '0')
    const min = date.getUTCMinutes().toString().padStart(2, '0')
    const sec = date.getUTCSeconds().toString().padStart(2, '0')
    const ms = date.getUTCMilliseconds().toString()
    return `${y}-${m}-${d} ${h}:${min}:${sec}.${ms}`
}```

snorberhuis avatar Oct 21 '20 19:10 snorberhuis

I just found this the hard way too :-(

rpaterson avatar Dec 27 '20 14:12 rpaterson