Skip to content

Commit

Permalink
feat(Alerts): display updated_at timezone (#1890)
Browse files Browse the repository at this point in the history
* feat(Alerts): display updated_at timezone

* fixup: use Boston time
  • Loading branch information
thecristen authored Feb 15, 2024
1 parent 6b8026a commit fa86484
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions assets/ts/components/Alerts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { ReactElement, useState } from "react";
import { format, parseISO } from "date-fns";
import { Alert as AlertType, Lifecycle } from "../__v3api";
import { handleReactEnterKeyPress } from "../helpers/keyboard-events-react";
import { caret } from "../helpers/icon";
Expand All @@ -8,6 +7,7 @@ import shuttleIcon from "../../static/images/icon-shuttle-default.svg";
import cancelIcon from "../../static/images/icon-cancelled-default.svg";
import snowIcon from "../../static/images/icon-snow-default.svg";
import alertIcon from "../../static/images/icon-alerts-triangle.svg";
import { formatToBostonTime } from "../helpers/date";

interface Props {
alerts: AlertType[];
Expand Down Expand Up @@ -206,7 +206,8 @@ const alertDescription = (alert: AlertType): ReactElement<HTMLElement> => (
/>
{alert.updated_at && (
<div className="c-alert-item__updated">
Updated: {format(parseISO(alert.updated_at), "M/d/yyyy h:mm aa")}
Updated:{" "}
{formatToBostonTime(alert.updated_at, "M/d/yyyy h:mm aa zzz")}
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ exports[`it renders 1`] = `
<div
className="c-alert-item__updated"
>
Updated:
4/11/2019 9:33 AM
Updated:
4/11/2019 10:33 AM EDT
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions lib/alerts/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ defmodule Alerts.Parser do
defp parse_time(str) do
str
|> Timex.parse!("{ISO:Extended}")
# While the time strings are already notated with -05 Etc/GMT+5 or -04
# Etc/GMT+4 time zone, this additional conversion gives the DateTime a
# nicer timezone abbreviation (EST or EDT)
|> Timex.Timezone.convert("America/New_York")
end

# remove leading/trailing whitespace from description
Expand Down
2 changes: 1 addition & 1 deletion lib/dotcom_web/views/alert_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ defmodule DotcomWeb.AlertView do
Timex.format!(updated_at, "{M}/{D}/{YYYY}")
end

time = format_schedule_time(updated_at)
time = Timex.format!(updated_at, "{h12}:{m} {AM} {Zabbr}")

["Updated: ", date, 32, time]
end
Expand Down

0 comments on commit fa86484

Please sign in to comment.