Show created_at date in changelog generator

This commit is contained in:
Héctor Ramón Jiménez 2025-12-02 04:51:34 +01:00
parent 40b184f022
commit 242ba99964
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 65 additions and 2 deletions

42
Cargo.lock generated
View file

@ -756,6 +756,7 @@ name = "changelog"
version = "0.1.0"
dependencies = [
"iced",
"jiff",
"log",
"reqwest",
"serde",
@ -2853,6 +2854,47 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "jiff"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35"
dependencies = [
"jiff-static",
"jiff-tzdb-platform",
"log",
"portable-atomic",
"portable-atomic-util",
"serde_core",
"windows-sys 0.61.2",
]
[[package]]
name = "jiff-static"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "jiff-tzdb"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1283705eb0a21404d2bfd6eef2a7593d240bc42a0bdb39db0ad6fa2ec026524"
[[package]]
name = "jiff-tzdb-platform"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8"
dependencies = [
"jiff-tzdb",
]
[[package]]
name = "jni"
version = "0.21.1"

View file

@ -21,6 +21,7 @@ tokio.workspace = true
serde.workspace = true
serde.features = ["derive"]
jiff = "0.2"
webbrowser = "1"
tracing-subscriber = "0.3"

View file

@ -1,3 +1,4 @@
use jiff::Timestamp;
use serde::Deserialize;
use tokio::fs;
use tokio::process;
@ -306,6 +307,7 @@ pub struct PullRequest {
pub description: Option<String>,
pub labels: Vec<String>,
pub author: String,
pub created_at: Timestamp,
}
impl PullRequest {
@ -334,6 +336,7 @@ impl PullRequest {
body: Option<String>,
user: User,
labels: Vec<Label>,
created_at: String,
}
#[derive(Deserialize)]
@ -354,6 +357,7 @@ impl PullRequest {
description: schema.body,
labels: schema.labels.into_iter().map(|label| label.name).collect(),
author: schema.user.login,
created_at: schema.created_at.parse()?,
})
}
}
@ -371,6 +375,9 @@ pub enum Error {
#[error("the changelog format is not valid")]
InvalidFormat,
#[error("date could not be parsed: {0}")]
InvalidDate(#[from] jiff::Error),
}
impl From<io::Error> for Error {

View file

@ -24,6 +24,7 @@ enum Generator {
pending: Vec<changelog::Contribution>,
state: State,
preview: Vec<markdown::Item>,
timezone: jiff::tz::TimeZone,
},
Done,
}
@ -73,6 +74,7 @@ impl Generator {
pending,
state: State::Loading(contribution.clone()),
preview,
timezone: jiff::tz::TimeZone::system(),
};
Task::perform(
@ -235,6 +237,7 @@ impl Generator {
pending,
state,
preview,
timezone,
} => {
let progress = {
let total = pending.len() + changelog.len();
@ -297,9 +300,19 @@ impl Generator {
.spacing(10)
.wrap();
let created_at = text(
timezone
.to_datetime(pull_request.created_at)
.strftime("%B %d, %Y at %I:%M%p")
.to_string(),
)
.size(12);
column![
title,
labels,
row![labels, created_at]
.align_y(Center)
.spacing(10),
scrollable(description)
.spacing(10)
.width(Fill)
@ -370,6 +383,6 @@ impl Generator {
}
fn theme(&self) -> Theme {
Theme::TokyoNightStorm
Theme::CatppuccinMocha
}
}