Skip to content

Commit

Permalink
Merge pull request #134 from grafana/fix/report-title-date
Browse files Browse the repository at this point in the history
[fix] Update report title date format
  • Loading branch information
szkiba authored Jan 12, 2024
2 parents 613eb0b + 8be570d commit 88e8535
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
10 changes: 5 additions & 5 deletions dashboard/assets/packages/report/dist/index.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,29 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

const dateTimeFormatter = new Intl.DateTimeFormat("en-GB", {
const dateTimeFormatter = new Intl.DateTimeFormat("en-US", {
year: "numeric",
month: "short",
day: "numeric",
hour: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false
})

export const toDate = (date?: Date) => {
return date && dateTimeFormatter.format(new Date(date))
if (!date) {
return
}

const parts = dateTimeFormatter.formatToParts(new Date(date))

const year = parts.find((p) => p.type === "year")?.value
const month = parts.find((p) => p.type === "month")?.value
const day = parts.find((p) => p.type === "day")?.value
const hour = parts.find((p) => p.type === "hour")?.value
const minute = parts.find((p) => p.type === "minute")?.value
const second = parts.find((p) => p.type === "second")?.value

return `${year}-${month}-${day} ${hour}:${minute}:${second}`
}

0 comments on commit 88e8535

Please sign in to comment.