Get year from UTC date
This commit is contained in:
parent
a95db555ac
commit
6b574ff34b
5 changed files with 44 additions and 13 deletions
33
Cargo.lock
generated
33
Cargo.lock
generated
|
@ -488,9 +488,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"time 0.1.45",
|
||||
"wasm-bindgen",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -900,7 +903,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
|||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1167,6 +1170,7 @@ dependencies = [
|
|||
"askama",
|
||||
"askama_axum",
|
||||
"axum",
|
||||
"chrono",
|
||||
"dotenvy",
|
||||
"log",
|
||||
"migration",
|
||||
|
@ -1292,7 +1296,7 @@ checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
|
|||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
|
@ -1882,7 +1886,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"sqlx",
|
||||
"thiserror",
|
||||
"time",
|
||||
"time 0.3.17",
|
||||
"tracing",
|
||||
"url",
|
||||
"uuid",
|
||||
|
@ -1966,7 +1970,7 @@ dependencies = [
|
|||
"rust_decimal",
|
||||
"sea-query-derive 0.3.0",
|
||||
"serde_json",
|
||||
"time",
|
||||
"time 0.3.17",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
|
@ -1992,7 +1996,7 @@ dependencies = [
|
|||
"sea-query 0.28.3",
|
||||
"serde_json",
|
||||
"sqlx",
|
||||
"time",
|
||||
"time 0.3.17",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
|
@ -2286,7 +2290,7 @@ dependencies = [
|
|||
"sqlx-rt",
|
||||
"stringprep",
|
||||
"thiserror",
|
||||
"time",
|
||||
"time 0.3.17",
|
||||
"tokio-stream",
|
||||
"url",
|
||||
"uuid",
|
||||
|
@ -2408,6 +2412,17 @@ dependencies = [
|
|||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.17"
|
||||
|
@ -2780,6 +2795,12 @@ dependencies = [
|
|||
"try-lock",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
|
|
|
@ -11,9 +11,8 @@ license = "Apache-2.0"
|
|||
# Core
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
tracing-subscriber = "0.3.16"
|
||||
dotenvy = "0.15.6"
|
||||
log = "0.4.17"
|
||||
serde = { version = "1.0.152", features = ["derive"] }
|
||||
log = "0.4.17"
|
||||
|
||||
# Database
|
||||
sea-orm = { version = "0.11.0-rc.1", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros"] }
|
||||
|
@ -24,3 +23,9 @@ axum = "0.6.4"
|
|||
askama = { features = ["with-axum", "markdown"], git = "https://github.com/djc/askama.git" }
|
||||
askama_axum = { git = "https://github.com/djc/askama.git" }
|
||||
serde_json = "1.0.91"
|
||||
|
||||
# Development
|
||||
dotenvy = "0.15.6"
|
||||
|
||||
# Misc
|
||||
chrono = "0.4.23"
|
||||
|
|
|
@ -3,6 +3,7 @@ pub(crate) mod post_resolver;
|
|||
pub(crate) mod posts;
|
||||
|
||||
use askama::Template;
|
||||
use chrono::{Utc, Datelike};
|
||||
use crate::{block_types::BlockTypes, AppState};
|
||||
|
||||
use axum::extract::State;
|
||||
|
@ -121,7 +122,7 @@ pub(crate) async fn root(
|
|||
description: page_meta.clone().description,
|
||||
show_title: page_meta.clone().show_title,
|
||||
content_blocks,
|
||||
year: "2023".to_string(),
|
||||
year: Utc::now().date_naive().year().to_string(),
|
||||
draft: false,
|
||||
menu,
|
||||
settings
|
||||
|
|
|
@ -8,6 +8,8 @@ use crate::{block_types::BlockTypes, AppState};
|
|||
use crate::entities::{prelude::*, *};
|
||||
use sea_orm::*;
|
||||
|
||||
use chrono::{Utc, Datelike};
|
||||
|
||||
use super::{PageTemplate, NotFoundTemplate};
|
||||
|
||||
pub(crate) async fn resolver(
|
||||
|
@ -43,7 +45,7 @@ pub(crate) async fn resolver(
|
|||
Ok(page_result) => {
|
||||
match page_result {
|
||||
Some(page_result) => page_result,
|
||||
None => return (StatusCode::NOT_FOUND, NotFoundTemplate { slug, year: "2023".to_owned(), menu, settings }).into_response(),
|
||||
None => return (StatusCode::NOT_FOUND, NotFoundTemplate { slug, year: Utc::now().date_naive().year().to_string(), menu, settings }).into_response(),
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
|
@ -83,7 +85,7 @@ pub(crate) async fn resolver(
|
|||
description: page_meta.clone().description,
|
||||
show_title: page_meta.clone().show_title,
|
||||
content_blocks,
|
||||
year: "2023".to_string(),
|
||||
year: Utc::now().date_naive().year().to_string(),
|
||||
menu,
|
||||
settings
|
||||
}).into_response()
|
||||
|
|
|
@ -8,6 +8,8 @@ use crate::{block_types::BlockTypes, AppState};
|
|||
use crate::entities::{prelude::*, *};
|
||||
use sea_orm::*;
|
||||
|
||||
use chrono::{Utc, Datelike};
|
||||
|
||||
use super::{PostTemplate, NotFoundTemplate};
|
||||
|
||||
pub(crate) async fn resolver(
|
||||
|
@ -43,7 +45,7 @@ pub(crate) async fn resolver(
|
|||
Ok(post_result) => {
|
||||
match post_result {
|
||||
Some(post_result) => post_result,
|
||||
None => return (StatusCode::NOT_FOUND, NotFoundTemplate { slug, year: "2023".to_owned(), menu, settings }).into_response(),
|
||||
None => return (StatusCode::NOT_FOUND, NotFoundTemplate { slug, year: Utc::now().date_naive().year().to_string(), menu, settings }).into_response(),
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
|
@ -89,7 +91,7 @@ pub(crate) async fn resolver(
|
|||
publish_date: post_meta.clone().published.to_string(),
|
||||
last_updated,
|
||||
content_blocks,
|
||||
year: "2023".to_string(),
|
||||
year: Utc::now().date_naive().year().to_string(),
|
||||
menu,
|
||||
settings
|
||||
}).into_response()
|
||||
|
|
Reference in a new issue