fix dates not displaying properly

This commit is contained in:
shibao 2025-01-31 22:07:41 -05:00
parent 76834845a3
commit 839e1d7124
4 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,5 @@
# v0.9.13 # v0.9.13
- Fix dates not rendering properly in table
- Update deps - Update deps
# v0.9.12 # v0.9.12

View File

@ -1,7 +1,7 @@
export default { export default {
displayDate (el) { displayDate (el) {
const date = const date =
Intl.DateTimeFormat([], { timeZone: 'Etc/UTC', dateStyle: 'short' }) Intl.DateTimeFormat([], { timeZone: 'UTC', dateStyle: 'short' })
.format(new Date(el.dateTime)) .format(new Date(el.dateTime))
el.innerText = date el.innerText = date

View File

@ -1,7 +1,7 @@
export default { export default {
displayDateTime (el) { displayDateTime (el) {
const date = const date =
Intl.DateTimeFormat([], { dateStyle: 'short', timeStyle: 'long' }) Intl.DateTimeFormat([], { timeZone: 'UTC', dateStyle: 'short', timeStyle: 'long' })
.format(new Date(el.dateTime)) .format(new Date(el.dateTime))
el.innerText = date el.innerText = date

View File

@ -20,6 +20,7 @@ defmodule CanneryWeb.Components.TableComponent do
""" """
use CanneryWeb, :live_component use CanneryWeb, :live_component
alias Cannery.{ComparableDate, ComparableDateTime}
alias Phoenix.LiveView.Socket alias Phoenix.LiveView.Socket
require Integer require Integer
@ -110,7 +111,7 @@ defmodule CanneryWeb.Components.TableComponent do
end end
defp sort_by_custom_sort_value_or_value(rows, key, sort_mode, type) defp sort_by_custom_sort_value_or_value(rows, key, sort_mode, type)
when type in [Date, DateTime] do when type in [ComparableDate, ComparableDateTime, Date, DateTime] do
rows rows
|> Enum.sort_by( |> Enum.sort_by(
fn row -> fn row ->