diff --git a/.changeset/pretty-fireants-taste.md b/.changeset/pretty-fireants-taste.md index b3168a7671..db18c73b2f 100644 --- a/.changeset/pretty-fireants-taste.md +++ b/.changeset/pretty-fireants-taste.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog': patch --- -Migrated the package from using moment to Luxon. #4278 +Removed unused functions and the moment library. #4278 diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index 9e2d206467..2ca0b59539 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -42,7 +42,6 @@ "@types/react": "^16.9", "classnames": "^2.2.6", "git-url-parse": "^11.4.4", - "luxon": "^1.25.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-helmet": "6.1.0", diff --git a/plugins/catalog/src/components/CatalogPage/utils/timeUtil.js b/plugins/catalog/src/components/CatalogPage/utils/timeUtil.js index 4c5e98d97c..e464b1d8fb 100644 --- a/plugins/catalog/src/components/CatalogPage/utils/timeUtil.js +++ b/plugins/catalog/src/components/CatalogPage/utils/timeUtil.js @@ -14,36 +14,10 @@ * limitations under the License. */ -import { DateTime } from 'luxon'; import goodMorning from './locales/goodMorning.locales.json'; import goodAfternoon from './locales/goodAfternoon.locales.json'; import goodEvening from './locales/goodEvening.locales.json'; -/** - * Validates that a date is a valid ISO string. - * - * @param date A date string - * @returns {bool} Whether the date is valid or not. - */ -export function isValidDate(date) { - return DateTime.fromISO(date).isValid; -} - -/** - * Validates that a date is a valid ISO string and a specific format. - * - * @param date A date string - * @param format A format string to validate against. See https://moment.github.io/luxon/docs/manual/parsing.html#table-of-tokens for reference. - * @returns {bool} Whether the date is valid or not according to the format. - */ -export function isValidDateAndFormat(date, format) { - return DateTime.fromFormat(date, format).isValid; -} - -export function relativeTime(timestamp) { - return DateTime.fromISO(timestamp).toRelative(); -} - // Select a large random integer at startup, to prevent the greetings to change every time the user // navigates. const greetingRandomSeed = Math.floor(Math.random() * 1000000); diff --git a/plugins/catalog/src/components/CatalogPage/utils/timeUtil.test.js b/plugins/catalog/src/components/CatalogPage/utils/timeUtil.test.js index 809d2aeac4..81bcf57ae7 100644 --- a/plugins/catalog/src/components/CatalogPage/utils/timeUtil.test.js +++ b/plugins/catalog/src/components/CatalogPage/utils/timeUtil.test.js @@ -19,25 +19,6 @@ import { isValidDateAndFormat, getTimeBasedGreeting, } from './timeUtil'; -import { DateTime } from 'luxon'; - -it('validate isValidDate', () => { - expect(isValidDate(DateTime.local().toISO())).toBeTruthy(); - expect(isValidDate('2021-02-04 15:00:10')).toBeFalsy(); -}); - -it('validates time format', () => { - const valid = isValidDateAndFormat( - '1970-01-01 00:00:00', - 'yyyy-MM-dd hh:mm:ss', - ); - const invalid = isValidDateAndFormat( - '1970-01-01T00:00:00', - 'yyyy-MM-ddThh:mm:ss', - ); - expect(valid).toBeTruthy(); - expect(invalid).toBeFalsy(); -}); it('has greeting and language', () => { const greeting = getTimeBasedGreeting();