From 612e1ce5f2025bf9e41f15e05182dcb3fbf92fe1 Mon Sep 17 00:00:00 2001 From: Edoardo Mistretta <38187989+edoardomistretta@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:49:30 +0200 Subject: [PATCH] fix: toISODate, toISO and toSQLDate methods could return null when an InvalidDate is provided (#1406) --- src/datetime.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/datetime.js b/src/datetime.js index 0958787ad..e17d1adca 100644 --- a/src/datetime.js +++ b/src/datetime.js @@ -1823,7 +1823,7 @@ export default class DateTime { * @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00' * @example DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335' * @example DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400' - * @return {string} + * @return {string|null} */ toISO({ format = "extended", @@ -1850,7 +1850,7 @@ export default class DateTime { * @param {string} [opts.format='extended'] - choose between the basic and extended format * @example DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25' * @example DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525' - * @return {string} + * @return {string|null} */ toISODate({ format = "extended" } = {}) { if (!this.isValid) { @@ -1935,7 +1935,7 @@ export default class DateTime { /** * Returns a string representation of this DateTime appropriate for use in SQL Date * @example DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13' - * @return {string} + * @return {string|null} */ toSQLDate() { if (!this.isValid) {