Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit 5050e80

Browse files
authored
Changing timeline to show UTC and adding local time to tooltip (#3523)
* Changing timeline to show UTC and adding local time to tooltip
1 parent 8eee40a commit 5050e80

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

src/dispatch/static/dispatch/src/case/TimelineTab.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</v-btn>
1313
</v-row>
1414
<v-timeline v-if="events && events.length" dense clipped>
15+
<v-col class="text-right caption">(times in UTC)</v-col>
1516
<v-timeline-item
1617
v-for="event in sortedEvents"
1718
:key="event.id"
@@ -40,7 +41,7 @@
4041
<v-tooltip bottom>
4142
<template v-slot:activator="{ on, attrs }">
4243
<span v-bind="attrs" v-on="on" class="wavy-underline">{{
43-
event.started_at | formatRelativeDate
44+
event.started_at | formatToUTC
4445
}}</span>
4546
</template>
4647
<span class="pre-formatted">{{ event.started_at | formatToTimeZones }}</span>
@@ -88,4 +89,4 @@ export default {
8889
}
8990
</script>
9091

91-
<style scoped src="@/assets/styles/timeline.css" />
92+
<style scoped src="@/styles/timeline.css" />

src/dispatch/static/dispatch/src/filters.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,39 @@ import Vue from "vue"
22
import { parseISO, formatISO } from "date-fns"
33
import moment from "moment-timezone"
44

5+
const time_format = "YYYY-MM-DD HH:mm:ss"
6+
const zones_to_show = ["America/Los_Angeles", "America/New_York"]
7+
58
Vue.filter("formatDate", function (value) {
69
if (value) {
710
return formatISO(parseISO(value))
811
}
912
})
1013

14+
Vue.filter("formatToUTC", function (value) {
15+
if (value) {
16+
return moment(value).utc().format(time_format)
17+
}
18+
})
19+
20+
function formatTimeZone(time) {
21+
return `${time.format("z")}: ${time.format(time_format)}`
22+
}
23+
1124
Vue.filter("formatToTimeZones", function (value) {
1225
if (value) {
13-
let m = moment(value)
14-
return `UTC: ${value}\nPST: ${m
15-
.tz("America/Los_Angeles")
16-
.format("YYYY-MM-DD HH:mm:ss")}\nEST: ${m
17-
.tz("America/New_York")
18-
.format("YYYY-MM-DD HH:mm:ss")}`
26+
const m = moment(value)
27+
if (!m.isValid()) return value
28+
const local_zone_name = moment.tz.guess() || "America/Los_Angeles"
29+
const local_time = m.tz(local_zone_name)
30+
let tooltip_text = `${formatTimeZone(local_time)}`
31+
zones_to_show.forEach((zone) => {
32+
if (zone != local_zone_name) {
33+
const zoned_time = m.tz(zone)
34+
tooltip_text += `\n${formatTimeZone(zoned_time)}`
35+
}
36+
})
37+
return tooltip_text
1938
}
2039
})
2140

src/dispatch/static/dispatch/src/incident/TimelineTab.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</v-btn>
1313
</v-row>
1414
<v-timeline v-if="events && events.length" dense clipped>
15+
<v-col class="text-right caption">(times in UTC)</v-col>
1516
<v-timeline-item
1617
v-for="event in sortedEvents"
1718
:key="event.id"
@@ -40,7 +41,7 @@
4041
<v-tooltip bottom>
4142
<template v-slot:activator="{ on, attrs }">
4243
<span v-bind="attrs" v-on="on" class="wavy-underline">{{
43-
event.started_at | formatRelativeDate
44+
event.started_at | formatToUTC
4445
}}</span>
4546
</template>
4647
<span class="pre-formatted">{{ event.started_at | formatToTimeZones }}</span>
@@ -87,4 +88,4 @@ export default {
8788
}
8889
</script>
8990

90-
<style scoped src="@/assets/styles/timeline.css" />
91+
<style scoped src="@/styles/timeline.css" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.wavy-underline {
2+
text-decoration: underline;
3+
text-decoration-style: dotted;
4+
text-decoration-color: silver;
5+
text-decoration-thickness: 1px;
6+
text-underline-offset: 3px;
7+
}
8+
9+
.pre-formatted {
10+
white-space: pre;
11+
}

0 commit comments

Comments
 (0)