From 544f8ad54fc9e260833796770fe12db50d0b938e Mon Sep 17 00:00:00 2001 From: jkaplon Date: Tue, 28 Jul 2015 14:07:56 -0400 Subject: [PATCH] Convert to local time on index.hbs, split date and time values. Closes #24, #27 --- server.js | 10 ++++++++++ views/index.hbs | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 0ab9470..c0819fe 100644 --- a/server.js +++ b/server.js @@ -72,6 +72,16 @@ app.get('/', function(req, res){ console.log(err); } else { //console.log(rows); + + // Loop over elements in rows array, convert ugly UTC times to pretty local times. + rows.forEach(function(row){ + var localDtTm = moment.utc(new Date(row.MaxPub)); + localDtTm = moment(localDtTm).tz('America/New_York').format('MM-DD-YYYY HH:mm:ss'); + row.MaxPub = localDtTm; + row.MaxPubDate = moment(localDtTm).format('MM-DD-YYYY'); + row.MaxPubTime = moment(localDtTm).format('h:mm:ss a'); + }); + res.render('index', {cores: rows}, function(err, html) { if(err !== null) { console.log(err); diff --git a/views/index.hbs b/views/index.hbs index d1aad24..8d85bae 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -8,6 +8,7 @@ Location Last Update + @@ -33,7 +34,8 @@ Edit Details {{/if}} - {{this.MaxPub}} + {{this.MaxPubDate}} + {{this.MaxPubTime}} {{this.MaxStatus}} {{/each}}