Use cargo fmt

This commit is contained in:
Miraty 2023-02-21 15:48:27 +01:00
parent 7767e5e561
commit d92d2f5932
5 changed files with 42 additions and 29 deletions

View File

@ -1,8 +1,8 @@
pub use std::time::{SystemTime,UNIX_EPOCH};
use libdit::libdit::Dit;
use std::str::FromStr;
pub use libdit::libdit::unix_to_dit_string;
use libdit::libdit::Dit;
pub use libstardit::libstardit::unix_to_stardit;
use std::str::FromStr;
pub use std::time::{SystemTime, UNIX_EPOCH};
fn main() {
/*
@ -26,5 +26,11 @@ fn main() {
let stardit = unix_to_stardit(current_timestamp);
println!("{}\n{}, décade {}, {}", unix_to_dit_string(current_timestamp), stardit.year, stardit.weekade, stardit.day_name);
println!(
"{}\n{}, décade {}, {}",
unix_to_dit_string(current_timestamp),
stardit.year,
stardit.weekade,
stardit.day_name
);
}

View File

@ -5,7 +5,7 @@ pub mod libdit {
pub struct Dit {
pub deca: u16,
pub decim: u16,
pub desec: u16
pub desec: u16,
}
impl FromStr for Dit {
@ -15,7 +15,7 @@ pub mod libdit {
return Ok(Dit {
deca: u16::from_str_radix(&dit[0..1], 10)?,
decim: u16::from_str_radix(&dit[2..4], 10)?,
desec: u16::from_str_radix(&dit[5..7], 10)?
desec: u16::from_str_radix(&dit[5..7], 10)?,
});
}
}
@ -31,7 +31,7 @@ pub mod libdit {
return Dit {
deca: (dit * 10.0 % 10.0) as u16,
decim: (dit * 1000.0 % 100.0) as u16,
desec: (dit * 100000.0 % 100.0) as u16
desec: (dit * 100000.0 % 100.0) as u16,
};
}
@ -45,6 +45,11 @@ pub mod libdit {
/// ```
pub fn unix_to_dit_string(unix: f64) -> String {
let dit = unix_to_dit_struct(unix);
return format!("{}.{}.{}", dit.deca, format!("{:0>2}", dit.decim), format!("{:0>2}", dit.desec));
return format!(
"{}.{}.{}",
dit.deca,
format!("{:0>2}", dit.decim),
format!("{:0>2}", dit.desec)
);
}
}

View File

@ -1,13 +1,13 @@
extern crate chrono;
pub mod libstardit {
use chrono::{TimeZone, Datelike, LocalResult};
use chrono::{Datelike, LocalResult, TimeZone};
pub struct StarDIT {
pub year: u16,
pub weekade: u16,
pub day_name: String,
pub day: u16
pub day: u16,
}
pub fn unix_to_stardit(unix: f64) -> StarDIT {
@ -31,7 +31,8 @@ pub mod libstardit {
8 => "octidi",
9 => "nonidi",
_ => "?",
}.to_string(),
}
.to_string(),
day: day,
};
}

1
rustfmt.toml Normal file
View File

@ -0,0 +1 @@
hard_tabs = true

View File

@ -1,5 +1,5 @@
pub use std::time::{SystemTime,UNIX_EPOCH};
pub use libstardit::libstardit::unix_to_stardit;
pub use std::time::{SystemTime, UNIX_EPOCH};
fn main() {
let current_timestamp = SystemTime::now()
@ -52,5 +52,5 @@ fn main() {
}
fn is_leap_year(year: i32) -> bool {
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
}