aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2024-08-22 18:36:14 -0700
committerPinapelz <yukais@pinapelz.com>2024-08-22 18:36:41 -0700
commitb96331811a124a1cbb58219faeb826462c46964f (patch)
treee306638370ebc38a0b5e64f0130ef47624a8b222
parentad8a6e85e9bcba78d830a04ad3960961dc4014b6 (diff)
fix: eorzean time formula reciprocal
- reversed 12/22 -> 22/12 in appropriate formulas
-rw-r--r--src/eorzean_time.rs27
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
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage