From 50c2a47034fe74b262ad3b5ebaf4d83449ed54cc Mon Sep 17 00:00:00 2001 From: Nikola Bjelo Date: Tue, 30 Oct 2018 13:15:38 +0100 Subject: [PATCH] correcting date format --- client/src/Components/HostedEvents/Event.js | 6 ++++-- client/src/Components/Search/Event.js | 6 ++++-- client/src/utils/index.js | 6 +++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/src/Components/HostedEvents/Event.js b/client/src/Components/HostedEvents/Event.js index 24833190c..37599da1b 100644 --- a/client/src/Components/HostedEvents/Event.js +++ b/client/src/Components/HostedEvents/Event.js @@ -9,6 +9,8 @@ import { import { withStyles } from '@material-ui/core/styles' import styles from './styles' +import { toLocalTime } from '../../utils' + class Event extends React.Component { render () { const classes = this.props.classes @@ -25,8 +27,8 @@ class Event extends React.Component { {name} - From : {startDatetime} - To : {finishDatetime} + From : {toLocalTime(startDatetime)} + To : {toLocalTime(finishDatetime)} Hosted by: {host.alias} ({host.lastName} {host.firstName}) diff --git a/client/src/Components/Search/Event.js b/client/src/Components/Search/Event.js index 5b88cf195..bce6d2433 100644 --- a/client/src/Components/Search/Event.js +++ b/client/src/Components/Search/Event.js @@ -9,6 +9,8 @@ import { import { withStyles } from '@material-ui/core/styles' import styles from './styles' +import { toLocalTime } from '../../utils' + class Event extends React.Component { render () { const classes = this.props.classes @@ -25,8 +27,8 @@ class Event extends React.Component { {name} - From : {startDatetime} - To : {finishDatetime} + From : {toLocalTime(startDatetime)} + To : {toLocalTime(finishDatetime)} Hosted by: {host.alias} ({host.lastName} {host.firstName}) diff --git a/client/src/utils/index.js b/client/src/utils/index.js index 4aee66165..36ed3a467 100644 --- a/client/src/utils/index.js +++ b/client/src/utils/index.js @@ -2,5 +2,9 @@ export const toLocalTime = (epoch) => { let localDate = new Date(0) localDate.setUTCSeconds(epoch) var options = { year: 'numeric', month: 'long', day: '2-digit' } - return localDate.toLocaleDateString(options) + ' ' + localDate.toLocaleTimeString('en-US') + return ( + localDate.toLocaleDateString(options) + + ' at ' + + localDate.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' }) + ) }