Created
November 21, 2020 01:53
-
-
Save seanogdev/16ec23c7c5a576cd9fc1fe0a29e74e16 to your computer and use it in GitHub Desktop.
Override Luxon formatters example
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
import { DateTime } from 'luxon'; | |
export default class CustomLuxonDateTime extends DateTime { | |
toISO(opts = {}) { | |
if (!this.isValid) { | |
return null; | |
} | |
const timeOpts = { | |
suppressMilliseconds: true, | |
...opts, | |
}; | |
return `${this.toISODate(opts)}T${this.toISOTime(timeOpts)}`; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment