-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.x] Format dates to browsers timezone (#417)
* Cache card * Exceptions card * Queues card * Servers card * Slow jobs card * Slow outgoing requests card * Slow queries card * Slow requests card * Usage card
- Loading branch information
1 parent
5dd3cd2
commit 382a301
Showing
12 changed files
with
38 additions
and
14 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
import Chart from 'chart.js/auto'; | ||
|
||
const formatDate = (value) => { | ||
if (value.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/) === null) { | ||
throw new Error(`Unknown date format [${value}].`); | ||
} | ||
|
||
const [date, time] = value.split(' ') | ||
const [year, month, day] = date.split('-').map(Number) | ||
const [hour, minute, second] = time.split(':').map(Number) | ||
|
||
return new Date( | ||
Date.UTC(year, month - 1, day, hour, minute, second, 0) | ||
).toLocaleString(undefined, { | ||
year: "2-digit", | ||
day: "2-digit", | ||
month: "2-digit", | ||
hourCycle: "h24", | ||
hour: "2-digit", | ||
minute: "2-digit", | ||
second: "2-digit", | ||
timeZoneName: "short" | ||
}); | ||
} | ||
|
||
window.Chart = Chart; | ||
window.formatDate = formatDate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters