From bb12407f9831f9c9d025bbf765674bb495b06429 Mon Sep 17 00:00:00 2001 From: Dan Rice Date: Tue, 10 May 2022 22:31:26 -0400 Subject: [PATCH] Remove date formatter --- js/app.js | 6 ------ js/dates.js | 24 ------------------------ js/dates.test.js | 22 ---------------------- package-lock.json | 14 -------------- package.json | 1 - 5 files changed, 67 deletions(-) delete mode 100644 js/dates.js delete mode 100644 js/dates.test.js diff --git a/js/app.js b/js/app.js index a205967..b648609 100644 --- a/js/app.js +++ b/js/app.js @@ -5,8 +5,6 @@ import '@popperjs/core' import $ from 'jquery' import Josh from 'joshjs' -let dates = require('./dates') - new Josh() $(function () { @@ -19,7 +17,3 @@ $(function () { .html("Selected File:
" + fileName + '
') }) }) - -document.querySelectorAll('.date-time').forEach((d) => { - d.innerHTML = dates.formatDateTime(d.innerHTML) -}) diff --git a/js/dates.js b/js/dates.js deleted file mode 100644 index 6e25249..0000000 --- a/js/dates.js +++ /dev/null @@ -1,24 +0,0 @@ -const moment = require('moment') - -const formatDateTime = datetime => { - /* - Safari wants strict iso8601 format "YYYY-MM-DDTHH:MM:SSZ", - but elixir to_string default supplies as "YYYY-MM-DD HH:MM:SSZ". - So this attempts to transform the dates if needed - */ - datetime = datetime - .trim() - .split(' ') - .join('T') - - if (datetime === 'never' || datetime === '') { - return datetime - } else { - return moment - .utc(datetime) - .local() - .format('MMM Do, YYYY [at] h:mma') - } -} - -module.exports = { formatDateTime } diff --git a/js/dates.test.js b/js/dates.test.js deleted file mode 100644 index ca0cc7f..0000000 --- a/js/dates.test.js +++ /dev/null @@ -1,22 +0,0 @@ -const dates = require('./dates') -const moment = require('moment') - -describe('formatDateTime', () => { - test('formats ISO 8601 dates', () => { - let date = new Date() - let testDate = moment - .utc(date) - .local() - .format('MMM Do, YYYY [at] h:mma') - - expect(dates.formatDateTime(date.toISOString())).toBe(testDate) - }) - - test('preserves "never" value', () => { - expect(dates.formatDateTime('never')).toBe('never') - }) - - test('handles white space around "never" value', () => { - expect(dates.formatDateTime(' never ')).toBe('never') - }) -}) diff --git a/package-lock.json b/package-lock.json index cf575b4..36f774d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "bootstrap": "^5.1.3", "joshjs": "^1.0.7", "jquery": "^3.6.0", - "moment": "^2.29.2", "xterm": "^4.18.0", "xterm-addon-fit": "^0.5.0" }, @@ -8656,14 +8655,6 @@ "node": ">=10" } }, - "node_modules/moment": { - "version": "2.29.2", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz", - "integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==", - "engines": { - "node": "*" - } - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -18438,11 +18429,6 @@ "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", "dev": true }, - "moment": { - "version": "2.29.2", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz", - "integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==" - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index 0c0b4c9..e216da9 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "bootstrap": "^5.1.3", "joshjs": "^1.0.7", "jquery": "^3.6.0", - "moment": "^2.29.2", "xterm": "^4.18.0", "xterm-addon-fit": "^0.5.0" },