Last active
November 12, 2022 12:41
-
-
Save damianof/bc8dba42e283f195aef4cf851a63a8bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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