Skip to content

Commit 2e7f233

Browse files
committed
#66 Show dates with browser timezone/locale
1 parent 9ba1f0d commit 2e7f233

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"jquery": "^3.1.1",
1717
"laravel-echo": "^1.3.5",
1818
"laravel-elixir": "^4.0.0",
19+
"moment": "^2.24.0",
1920
"pretty-data": "^0.40.0",
2021
"pusher-js": "^4.2.2"
2122
},

public/css/app.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/bundle.js

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/js/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
var prettyData = require('pretty-data').pd;
1+
let prettyData = require('pretty-data').pd;
2+
let moment = require('moment');
23

34
angular
45
.module("app", [
@@ -517,6 +518,14 @@ angular
517518
return content;
518519
};
519520

521+
$scope.localDate = (function (dateTimeString) {
522+
return moment.utc(dateTimeString).local().format('lll');
523+
});
524+
525+
$scope.relativeDate = (function (dateTimeString) {
526+
return moment.utc(dateTimeString).fromNow();
527+
});
528+
520529
// Initialize app. Check whether we need to load a token.
521530
if ($state.current.name) {
522531
if ($scope.getSetting('token') && !$stateParams.id) {

resources/views/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class="btn btn-xs btn-link">
9292
<a ng-click="setCurrentRequest(request)" class="select">
9393
<span class="label label-{{ getLabel(request.method) }}">{{ request.method }}</span>
9494
#{{ request.uuid.substring(0,5) }} {{ request.ip }} <br/>
95-
<small>{{ request.created_at }}</small>
95+
<small>{{ localDate(request.created_at) }}</small>
9696
</a>
9797
<a ng-click="deleteRequest(request, key)" class="btn btn-danger delete">
9898
X
@@ -246,7 +246,7 @@ class="btn btn-xs" ng-class="redirectUrl ? '' : 'disabled'"
246246
</tr>
247247
<tr>
248248
<td>Date</td>
249-
<td id="req-date">{{ currentRequest.created_at }}</td>
249+
<td id="req-date" title="{{ currentRequest.created_at }} UTC">{{ localDate(currentRequest.created_at) }} ({{ relativeDate(currentRequest.created_at) }})</td>
250250
</tr>
251251
<tr>
252252
<td>ID</td>

0 commit comments

Comments
 (0)