Rename the new_time function

This commit is contained in:
Savanni D'Gerinel 2023-06-20 23:58:25 -04:00
parent 3a82cd229d
commit 972b045b21
1 changed files with 5 additions and 5 deletions

View File

@ -20,16 +20,16 @@ pub struct SunMoon {
impl SunMoon {
fn from_js(day: Date<Tz>, val: SunMoonJs) -> Self {
fn kreu_tempo(day: Date<Tz>, val: String) -> Option<DateTime<Tz>> {
fn new_time(day: Date<Tz>, val: String) -> Option<DateTime<Tz>> {
NaiveTime::parse_from_str(&val, "%H:%M")
.map(|tempo| day.and_hms(tempo.hour(), tempo.minute(), 0))
.ok()
}
let sunrise = kreu_tempo(day.clone(), val.sunrise).unwrap();
let sunset = kreu_tempo(day.clone(), val.sunset).unwrap();
let moonrise = val.moonrise.and_then(|v| kreu_tempo(day.clone(), v));
let moonset = val.moonset.and_then(|v| kreu_tempo(day.clone(), v));
let sunrise = new_time(day.clone(), val.sunrise).unwrap();
let sunset = new_time(day.clone(), val.sunset).unwrap();
let moonrise = val.moonrise.and_then(|v| new_time(day.clone(), v));
let moonset = val.moonset.and_then(|v| new_time(day.clone(), v));
Self {
sunrise,