From c15b72666bb721933379f21706270cc4945ba751 Mon Sep 17 00:00:00 2001 From: Jari Bakken Date: Wed, 4 Feb 2015 17:47:37 +0000 Subject: [PATCH] Improve date formatting in log view. --- package.json | 10 ++++++++-- public/js/components/log/LogEntry.jsx | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e7f250d9ae..c24c85d044 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "jsxhint": "0.4.15", "knex": "^0.7.3", "log4js": "0.6.21", + "moment": "^2.9.0", "nconf": "0.6.9", "pg": "3.6.1", "react": "^0.12.0", @@ -68,7 +69,12 @@ }, "jest": { "scriptPreprocessor": "/jest-preprocessor.js", - "unmockedModulePathPatterns": ["/node_modules/react"], - "moduleFileExtensions": ["jsx", "js"] + "unmockedModulePathPatterns": [ + "/node_modules/react" + ], + "moduleFileExtensions": [ + "jsx", + "js" + ] } } diff --git a/public/js/components/log/LogEntry.jsx b/public/js/components/log/LogEntry.jsx index 12cf37f315..d246139c45 100644 --- a/public/js/components/log/LogEntry.jsx +++ b/public/js/components/log/LogEntry.jsx @@ -1,4 +1,5 @@ var React = require('react'); +var moment = require('moment'); var DIFF_PREFIXES = { A: ' ', @@ -20,13 +21,13 @@ var LogEntry = React.createClass({ }, render: function() { - var d = new Date(this.props.event.createdAt); + var date = moment(this.props.event.createdAt); return ( - {d.getDate() + "." + (d.getMonth() + 1) + "." + d.getFullYear()}
- kl. {d.getHours() + "." + d.getMinutes()} + {date.format('ll')}
+ {date.format('HH:mm')} {this.props.event.data.name}[{this.props.event.type}]