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
- Fix dates not rendering properly in table
- Update deps
# v0.9.12

View File

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

View File

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

View File

@ -20,6 +20,7 @@ defmodule CanneryWeb.Components.TableComponent do
"""
use CanneryWeb, :live_component
alias Cannery.{ComparableDate, ComparableDateTime}
alias Phoenix.LiveView.Socket
require Integer
@ -110,7 +111,7 @@ defmodule CanneryWeb.Components.TableComponent do
end
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
|> Enum.sort_by(
fn row ->