This commit is contained in:
JMARyA 2025-01-08 20:42:43 +01:00
parent 86dbdcf75d
commit dde84caa53
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 15 additions and 4 deletions

View file

@ -36,12 +36,24 @@ pub fn format_date(date: &chrono::NaiveDate) -> String {
///
/// let number = 12345;
/// let formatted = format_number(number);
/// assert_eq!(formatted, "12345");
/// assert_eq!(formatted, "12.345");
/// ```
#[must_use]
pub fn format_number(num: i32) -> String {
// TODO : Implement custom formatting
num.to_string()
let mut str = num.to_string();
let mut result = String::new();
let mut count = 0;
str = str.chars().rev().collect();
for (i, c) in str.chars().enumerate() {
if i != 0 && i % 3 == 0 {
result.push('.');
}
result.push(c);
}
result.chars().rev().collect()
}
/// Converts a number of seconds into a formatted string in `HH:MM:SS` or `MM:SS` format.

View file

@ -8,7 +8,6 @@ pub mod page;
pub mod request;
pub mod result;
// TODO : API Pagination?
// TODO : CORS?
// Postgres