mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Fix a bug with time zone reporting in alerts.
This commit is contained in:
@@ -124,16 +124,13 @@ function addAlertRowsToTable(tbody, alerts) {
|
||||
var showRef = $("#tableShowRef")[0].checked;
|
||||
|
||||
// Get times for the alert, and convert to local time if necessary.
|
||||
var start_time_unix = moment.unix(a["start_time"]);
|
||||
var start_time = start_time_unix.utc();
|
||||
if (useLocalTime) {
|
||||
start_time = start_time.local();
|
||||
}
|
||||
var end_time_unix = moment.unix(a["end_time"]);
|
||||
var end_time = end_time_unix.utc();
|
||||
if (useLocalTime) {
|
||||
end_time = end_time.local();
|
||||
}
|
||||
var start_time_utc = moment.unix(a["start_time"]).utc();
|
||||
var start_time_local = start_time_utc.clone().local();
|
||||
console.log(a["dx_calls"])
|
||||
start_time = useLocalTime ? start_time_local : start_time_utc;
|
||||
var end_time_utc = moment.unix(a["end_time"]).utc();
|
||||
var end_time_local = end_time_utc.clone().local();
|
||||
end_time = useLocalTime ? end_time_local : end_time_utc;
|
||||
|
||||
// Format the times for display. Start time is displayed as e.g. 7 Oct 12:34 unless the time is in a
|
||||
// different year to the current year, in which case the year is inserted between month and hour.
|
||||
@@ -143,8 +140,8 @@ function addAlertRowsToTable(tbody, alerts) {
|
||||
// Overriding all of that, if the start time is 00:00 and the end time is 23:59 when considered in UTC, the
|
||||
// hours and minutes are stripped out from the display, as we assume the server is just giving us full days.
|
||||
// Finally, if there is no end date set, "---" is displayed.
|
||||
var whole_days = start_time_unix.utc().format("HH:mm") == "00:00" &&
|
||||
(end_time_unix != null || end_time_unix > 0 || end_time_unix.utc().format("HH:mm") == "23:59");
|
||||
var whole_days = start_time_utc.format("HH:mm") == "00:00" &&
|
||||
(end_time_utc != null || end_time_utc > 0 || end_time_utc.format("HH:mm") == "23:59");
|
||||
var hours_minutes_format = whole_days ? "" : " HH:mm";
|
||||
var start_time_formatted = start_time.format("D MMM" + hours_minutes_format);
|
||||
if (start_time.format("YYYY") != moment().format("YYYY")) {
|
||||
@@ -153,11 +150,13 @@ function addAlertRowsToTable(tbody, alerts) {
|
||||
start_time_formatted = start_time.format("[Today]" + hours_minutes_format);
|
||||
}
|
||||
var end_time_formatted = "---";
|
||||
if (end_time_unix != null && end_time_unix > 0 && end_time != null) {
|
||||
if (end_time_utc != null && end_time_utc > 0 && end_time != null) {
|
||||
var end_time_formatted = whole_days ? start_time_formatted : end_time.format("HH:mm");
|
||||
if (end_time.format("D MMM") != start_time.format("D MMM")) {
|
||||
if (end_time.format("YYYY") != moment().format("YYYY")) {
|
||||
end_time_formatted = end_time.format("D MMM YYYY" + hours_minutes_format);
|
||||
} else if (useLocalTime && end_time.format("D MMM YYYY") == moment().format("D MMM YYYY")) {
|
||||
end_time_formatted = end_time.format("[Today]" + hours_minutes_format);
|
||||
} else {
|
||||
end_time_formatted = end_time.format("D MMM" + hours_minutes_format);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user