Skip to content

Commit

Permalink
fix(about-page): render undefined date strings as "N/A" (v34)
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikThePendric authored Feb 24, 2020
2 parents 98358cc + ace8cb5 commit 132483c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
4 changes: 3 additions & 1 deletion i18n/module/i18n_module_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,6 @@ no=No
password_changed_successfully=Password changed successfully
login_again=You need to login again to continue using the application.
login=Login
login=Login
never=Never
invalid_date=Invalid date
30 changes: 19 additions & 11 deletions src/aboutPage/AboutPage.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ import PropTypes from 'prop-types';
import AboutSection from './AboutSection.component';

const parseDateFromUTCString = (utcString, d2) => {
const locale = d2.currentUser.userSettings.settings.keyUiLocale;
const date = new Date(utcString);
const options = {
day: 'numeric',
month: 'long',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: false,
};
return new Intl.DateTimeFormat(locale, options).format(date);
try {
if (!utcString) {
return d2.i18n.getTranslation('never')
}

const locale = d2.currentUser.userSettings.settings.keyUiLocale;
const date = new Date(utcString);
const options = {
day: 'numeric',
month: 'long',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: false,
};
return new Intl.DateTimeFormat(locale, options).format(date);
} catch (error) {
return d2.i18n.getTranslation('invalid_date')
}
};

const attributes = {
Expand Down

0 comments on commit 132483c

Please sign in to comment.