Skip to content

Commit d94ac2e

Browse files
committed
backend/send_chargelog_to_user: Fix month calculation
1 parent 142235c commit d94ac2e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

backend/src/routes/send_chargelog_to_user.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,17 @@ pub async fn send_chargelog(
130130
#[cfg(test)]
131131
let lang_str = String::from("en");
132132

133+
let Some(last_month) = chrono::Utc::now()
134+
.date_naive()
135+
.checked_sub_months(chrono::Months::new(1))
136+
else {
137+
return Err(Error::InternalError.into());
138+
};
133139
let month = match lang_str.as_str() {
134-
"de" => chrono::Utc::now()
140+
"de" => last_month
135141
.format_localized("%B %Y", chrono::Locale::de_DE)
136142
.to_string(),
137-
_ => chrono::Utc::now().format("%B %Y").to_string(),
143+
_ => last_month.format("%B %Y").to_string(),
138144
};
139145

140146
let (body, subject) = render_chargelog_email(&user.name, &month, &payload.filename, &lang_str)?;

0 commit comments

Comments
 (0)