diff --git a/public/js/app/components/preview/CourseFacts.jsx b/public/js/app/components/preview/CourseFacts.jsx index 4161f46c..b6a5de50 100644 --- a/public/js/app/components/preview/CourseFacts.jsx +++ b/public/js/app/components/preview/CourseFacts.jsx @@ -98,7 +98,7 @@ const startDate = (labels, memoData) => memoData.roundsStartDate ? ( <>

{labels.startdate}

-

{getDateFormat(memoData.roundsStartDate[0])}

+

{getDateFormat(memoData.roundsStartDate[0], memoData.languageOfInstructions)}

) : ( <> diff --git a/public/js/app/components/preview/CourseMemoLinks.jsx b/public/js/app/components/preview/CourseMemoLinks.jsx index 800c9ee8..a2febe26 100644 --- a/public/js/app/components/preview/CourseMemoLinks.jsx +++ b/public/js/app/components/preview/CourseMemoLinks.jsx @@ -1,26 +1,24 @@ import React from 'react' import PropTypes from 'prop-types' +import { getDateFormat } from '../../util/helpers' import Popup from './Popup' -const formatVersion = (language = 'sv', version) => { - const unixTime = Date.parse(version) +const formatVersionDateAndTime = (language = 'sv', lastChangedDateTime) => { + const unixTime = Date.parse(lastChangedDateTime) if (unixTime) { - if (language === 'sv') { - return new Date(unixTime).toLocaleString('sv-SE') - } else { - const options = { day: 'numeric', month: 'short', year: 'numeric' } - return new Date(unixTime).toLocaleDateString('en-GB', options) - } + const date = new Date(unixTime) + const time = date.toLocaleTimeString() + return `${getDateFormat(date, language)} ${time}` } return null } -const version = (language, labels, memoVersion) => - memoVersion ? ( +const version = (language, labels, lastChangedDateTime, memoData) => + lastChangedDateTime ? ( <>

{labels.versionTitle}

-

{`${labels.latest} ${formatVersion(language, memoVersion)}`}

+

{`Ver ${memoData.version} - ${formatVersionDateAndTime(language, lastChangedDateTime)}`}

) : ( <> @@ -41,7 +39,7 @@ const pdfLink = labels => ( const CourseMemoLinks = ({ language, labels, memoData = {} }) => (
- {version(language, labels, memoData.lastChangeDate)} + {version(language, labels, memoData.lastChangeDate, memoData)} {pdfLink(labels)}
) diff --git a/public/js/app/util/helpers.js b/public/js/app/util/helpers.js index 5178d3cf..20a4b914 100644 --- a/public/js/app/util/helpers.js +++ b/public/js/app/util/helpers.js @@ -17,12 +17,12 @@ export const combinedCourseName = (courseCode, course, langAbbr) => { } export const getDateFormat = (date, language) => { + const timestamp = Date.parse(date) + const parsedDate = new Date(timestamp) if (language === 1 || language === 'Svenska' || language === 'Swedish' || language === 'sv') { - return date + return parsedDate.toLocaleDateString('sv') } const options = { day: 'numeric', month: 'short', year: 'numeric' } - const timestamp = Date.parse(date) - const parsedDate = new Date(timestamp) return parsedDate.toLocaleDateString('en-GB', options) }