diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/eorzean_time.rs | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/eorzean_time.rs b/src/eorzean_time.rs index e6ac83b..366630b 100644 --- a/src/eorzean_time.rs +++ b/src/eorzean_time.rs @@ -63,8 +63,6 @@ pub struct EorzeanDate { pub minutes: u64, } - - /// Handles i64 and DateTime<Utc> types pub trait ToUnixTimestamp { /// Converts the implementing type to a Unix timestamp. @@ -151,8 +149,8 @@ pub fn convert_to_eorzean_time<T: ToUnixTimestamp>(input_time: T) -> (u8, u8) { /// /// # Returns /// - An `EorzeanTime` struct representing the Eorzean time equivalent of the input seconds -pub fn convert_seconds_to_eorzean_duration(seconds: f64) -> EorzeanTime { - let eorzean_seconds = seconds * EORZEA_CONSTANT; +pub fn convert_earth_seconds_to_eorzean_duration(seconds: f64) -> EorzeanTime { + let eorzean_seconds = seconds * 22.0/12.0; let years = (eorzean_seconds / EORZEA_SECONDS_PER_YEAR) as u64; let remaining_seconds = eorzean_seconds % EORZEA_SECONDS_PER_YEAR; @@ -183,21 +181,20 @@ pub fn convert_seconds_to_eorzean_duration(seconds: f64) -> EorzeanTime { } } -/// Converts an EorzeanDuration to seconds +/// Converts an EorzeanDuration to Earth seconds /// /// # Arguments /// - `eorzean_duration` - An `EorzeanTime` struct representing the Eorzean time equivalent of the input seconds /// /// # Returns /// - A `i64` representing the number of seconds to convert -pub fn convert_eorzean_duration_to_seconds(eorzean_duration: EorzeanTime) -> i64 { - let total_seconds = (eorzean_duration.years as f64 * EORZEA_SECONDS_PER_YEAR) - + (eorzean_duration.moons as f64 * EORZEA_SECONDS_PER_MOON) - + (eorzean_duration.weeks as f64 * EORZEA_SECONDS_PER_WEEK) - + (eorzean_duration.suns as f64 * EORZEA_SECONDS_PER_SUN) - + (eorzean_duration.bells as f64 * EORZEA_SECONDS_PER_HOUR) - + (eorzean_duration.minutes as f64 * EORZEA_SECONDS_PER_MINUTE) - + eorzean_duration.seconds as f64; - - total_seconds as i64 +pub fn convert_eorzean_duration_to_earth_seconds(eorzean_duration: EorzeanTime) -> i64 { + let total_seconds = eorzean_duration.years as f64 * EORZEA_SECONDS_PER_YEAR + + eorzean_duration.moons as f64 * EORZEA_SECONDS_PER_MOON + + eorzean_duration.weeks as f64 * EORZEA_SECONDS_PER_WEEK + + eorzean_duration.suns as f64 * EORZEA_SECONDS_PER_SUN + + eorzean_duration.bells as f64 * EORZEA_SECONDS_PER_HOUR + + eorzean_duration.minutes as f64 * EORZEA_SECONDS_PER_MINUTE + + eorzean_duration.seconds as f64; + (total_seconds as i64 * 12/22) as i64 } |
