Skip to content

Instantly share code, notes, and snippets.

@damianof
Last active November 12, 2022 12:41
Show Gist options
  • Save damianof/bc8dba42e283f195aef4cf851a63a8bb to your computer and use it in GitHub Desktop.
Save damianof/bc8dba42e283f195aef4cf851a63a8bb to your computer and use it in GitHub Desktop.
const { DateTime } = require('luxon')
const test1 = () => {
let startIsoDate = '2024-02-28T00:00:00.000Z'
let expected = '2023-02-28T00:00:00.000Z'
let result = DateTime.fromISO(startIsoDate, { zone: 'UTC' }).toUTC().plus({
year: -1
}).toISO()
console.assert(expected !== result, 'test1 Failed')
console.log('test1 result', expected === result, result)
}
const test2 = () => {
let startIsoDate = '2024-02-29T00:00:00.000Z'
let expected = '2023-03-01T00:00:00.000Z'
let result = DateTime.fromISO(startIsoDate, { zone: 'UTC' }).toUTC().plus({
year: -1
}).toISO()
console.assert(expected !== result, 'test2 Failed')
console.log('test2 result', expected === result, result)
}
test1()
test2()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment