Skip to content

Commit

Permalink
chore: replace deprecated Duration::days with Duration::try_days
Browse files Browse the repository at this point in the history
  • Loading branch information
shenek committed Mar 8, 2024
1 parent 28622f6 commit 386961e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ucelofka-data/src/invoice/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Invoice {
_version: VERSION,
id: new_id,
issue_day: Utc::now().format("%Y-%m-%d").to_string(),
due_day: (Utc::now() + Duration::days(DEFAULT_DUE))
due_day: (Utc::now() + Duration::try_days(DEFAULT_DUE).unwrap_or_default())
.format("%Y-%m-%d")
.to_string(),
issuer: Issuer {
Expand Down
5 changes: 3 additions & 2 deletions ucelofka-data/src/invoice/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ impl Invoice {
id: new_id,
issue_date: Utc::now().format("%Y-%m-%d").to_string(),
due_date: (Utc::now()
+ Duration::days(
+ Duration::try_days(
due.map(|v| i64::try_from(v).unwrap())
.unwrap_or(DEFAULT_DUE),
))
)
.unwrap_or_default())
.format("%Y-%m-%d")
.to_string(),
issuer: Issuer {
Expand Down

0 comments on commit 386961e

Please sign in to comment.