pub mod i18n;
pub mod case_expr;
pub mod pagination;
pub mod filter;
pub mod telegram_stars;
pub mod markdown_restorer;

pub fn format_bytes(bytes: i64) -> String {
    let b = bytes as f64;
    if b < 1024.0 {
        format!("{} B", bytes)
    } else if b < 1024.0 * 1024.0 {
        format!("{:.2} KB", b / 1024.0)
    } else if b < 1024.0 * 1024.0 * 1024.0 {
        format!("{:.2} MB", b / (1024.0 * 1024.0))
    } else {
        format!("{:.2} GB", b / (1024.0 * 1024.0 * 1024.0))
    }
}

pub fn format_mb(mb: i64) -> String {
    let mb = mb as f64;
    if mb < 1024.0 {
        format!("{:.2} MB", mb)
    } else {
        format!("{:.2} GB", mb / 1024.0)
    }
}
