From 92fdb87cf08acfc85d51ba2731782ce7c79a7500 Mon Sep 17 00:00:00 2001 From: schn33fuchs Date: Fri, 1 May 2026 18:11:40 +0200 Subject: [PATCH] Timezone now CET --- .../20260422094706_ticket_table.sql | 2 +- backend/src/models.rs | 4 +-- frontend/Cargo.lock | 35 +++++++++++++++++++ frontend/Cargo.toml | 1 + frontend/src/pages/ticket.rs | 7 ++-- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/backend/migrations/20260422094706_ticket_table.sql b/backend/migrations/20260422094706_ticket_table.sql index 5806f85..3602ec4 100644 --- a/backend/migrations/20260422094706_ticket_table.sql +++ b/backend/migrations/20260422094706_ticket_table.sql @@ -5,6 +5,6 @@ CREATE TABLE IF NOT EXISTS tickets ( description TEXT, room SMALLINT, status VARCHAR(15) NOT NULL DEFAULT 'ToDo', - date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + date TIMESTAMP WITH TIME ZONE DEFAULT now(), user_id SMALLINT DEFAULT 1 ); diff --git a/backend/src/models.rs b/backend/src/models.rs index 52c2e11..8dda925 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -11,7 +11,7 @@ pub struct Ticket { pub description: String, pub room: i16, pub status: String, - pub date: chrono::NaiveDateTime, + pub date: chrono::DateTime, pub user_id: i16, } @@ -23,7 +23,7 @@ pub struct TicketResponse { pub description: String, pub room: i16, pub status: String, - pub date: chrono::NaiveDateTime, + pub date: chrono::DateTime, pub user_id: i16, pub user_first_name: String, pub user_last_name: String, diff --git a/frontend/Cargo.lock b/frontend/Cargo.lock index 140ecf6..335d1a1 100644 --- a/frontend/Cargo.lock +++ b/frontend/Cargo.lock @@ -68,6 +68,16 @@ dependencies = [ "windows-link", ] +[[package]] +name = "chrono-tz" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6139a8597ed92cf816dfb33f5dd6cf0bb93a6adc938f11039f371bc5bcd26c3" +dependencies = [ + "chrono", + "phf", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -116,6 +126,7 @@ name = "frontend" version = "0.1.0" dependencies = [ "chrono", + "chrono-tz", "gloo 0.12.0", "gloo-net 0.7.0", "serde", @@ -735,6 +746,24 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "phf" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_shared" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.1.11" @@ -933,6 +962,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "siphasher" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" + [[package]] name = "slab" version = "0.4.12" diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml index cef7f39..96f66f2 100644 --- a/frontend/Cargo.toml +++ b/frontend/Cargo.toml @@ -24,3 +24,4 @@ yew-router = "0.20.0" serde_json = "1.0.149" gloo = "0.12.0" chrono = { version = "0.4.44", features = ["serde"] } +chrono-tz = "0.10.4" diff --git a/frontend/src/pages/ticket.rs b/frontend/src/pages/ticket.rs index b093142..72500b9 100644 --- a/frontend/src/pages/ticket.rs +++ b/frontend/src/pages/ticket.rs @@ -1,3 +1,4 @@ +use chrono_tz::Europe::Berlin; use gloo_net::http::Request; use serde::{Deserialize, Serialize}; use wasm_bindgen::JsCast; @@ -26,7 +27,7 @@ pub struct Ticket { pub description: String, pub room: i16, pub status: String, - pub date: chrono::NaiveDateTime, + pub date: chrono::DateTime, pub user_id: i16, pub user_first_name: String, pub user_last_name: String, @@ -310,7 +311,9 @@ pub fn ticket_by_id_component(props: &TicketProps) -> Html {

{ "Betreff: " }{ &t.betreff }

{ "Beschreibung: " }{ &t.description }

{ "Raum: " }{ t.room }

-

{ "Datum: " }{ &t.date }

+

{ "Datum: " }{ + t.date.with_timezone(&Berlin).format("%d.%m.%Y %H:%M:%S").to_string() + }

{ "Status: "}{ match t.status.as_str() { "ToDo" => "Zu tun", "InProgress" => "In Bearbeitung",