JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Change to new UTC chrono types

Emilia - ⁨1⁩ year ago

parent: tbd commit: ⁨779637c

Showing ⁨⁨2⁩ changed files⁩ with ⁨⁨6⁩ insertions⁩ and ⁨⁨8⁩ deletions⁩

giterated-daemon/src/backend/git/branches.rs

View file
@@ -61,7 +61,6 @@ impl GitBackend {
61 61 };
62 62
63 63 let stale = chrono::Utc::now()
64 .naive_utc()
65 64 .signed_duration_since(commit.time)
66 65 .num_seconds()
67 66 > stale_after.into();
@@ -172,7 +171,6 @@ impl GitBackend {
172 171
173 172 let stale = if let Some(ref last_commit) = last_commit {
174 173 chrono::Utc::now()
175 .naive_utc()
176 174 .signed_duration_since(last_commit.time)
177 175 .num_seconds()
178 176 > stale_after.into()

giterated-models/src/repository/mod.rs

View file
@@ -1,7 +1,7 @@
1 1 use std::fmt::{Display, Formatter};
2 2 use std::str::FromStr;
3 3
4 use chrono::NaiveDateTime;
4 use chrono::{DateTime, Utc};
5 5 use serde::{Deserialize, Serialize};
6 6
7 7 use crate::object::GiteratedObject;
@@ -190,7 +190,7 @@ pub struct RepositoryTag {
190 190 /// Signature of the tag author
191 191 pub author: Option<CommitSignature>,
192 192 /// Time the tag or pointed commit was created
193 pub time: Option<NaiveDateTime>,
193 pub time: Option<DateTime<Utc>>,
194 194 /// Commit the tag is pointing to
195 195 pub commit: Option<Commit>,
196 196 }
@@ -403,7 +403,7 @@ pub struct Commit {
403 403 /// Who committed the commit
404 404 pub committer: CommitSignature,
405 405 /// Time when the commit happened
406 pub time: chrono::NaiveDateTime,
406 pub time: chrono::DateTime<chrono::Utc>,
407 407 }
408 408
409 409 /// Gets all info from [`git2::Commit`] for easy use
@@ -427,7 +427,7 @@ impl From<git2::Commit<'_>> for Commit {
427 427 .collect::<Vec<String>>(),
428 428 author: commit.author().into(),
429 429 committer: commit.committer().into(),
430 time: chrono::NaiveDateTime::from_timestamp_opt(commit.time().seconds(), 0).unwrap(),
430 time: chrono::DateTime::from_timestamp(commit.time().seconds(), 0).unwrap(),
431 431 }
432 432 }
433 433 }
@@ -437,7 +437,7 @@ impl From<git2::Commit<'_>> for Commit {
437 437 pub struct CommitSignature {
438 438 pub name: Option<String>,
439 439 pub email: Option<String>,
440 pub time: chrono::NaiveDateTime,
440 pub time: chrono::DateTime<chrono::Utc>,
441 441 }
442 442
443 443 /// Converts the signature from git2 into something usable without explicit lifetimes.
@@ -446,7 +446,7 @@ impl From<git2::Signature<'_>> for CommitSignature {
446 446 Self {
447 447 name: signature.name().map(|name| name.to_string()),
448 448 email: signature.email().map(|email| email.to_string()),
449 time: chrono::NaiveDateTime::from_timestamp_opt(signature.when().seconds(), 0).unwrap(),
449 time: chrono::DateTime::from_timestamp(signature.when().seconds(), 0).unwrap(),
450 450 }
451 451 }
452 452 }