update
This commit is contained in:
parent
86dbdcf75d
commit
dde84caa53
2 changed files with 15 additions and 4 deletions
|
@ -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.
|
||||
|
|
|
@ -8,7 +8,6 @@ pub mod page;
|
|||
pub mod request;
|
||||
pub mod result;
|
||||
|
||||
// TODO : API Pagination?
|
||||
// TODO : CORS?
|
||||
|
||||
// Postgres
|
||||
|
|
Loading…
Add table
Reference in a new issue