aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2024-08-22 17:09:13 -0700
committerPinapelz <yukais@pinapelz.com>2024-08-22 17:09:13 -0700
commitad8a6e85e9bcba78d830a04ad3960961dc4014b6 (patch)
treed0dfaf4b3c66ec4f85d8e86154333b9ab7e3d69c
parent291195b17e40c9ebc75e6d0b25195a02596b59e1 (diff)
implement getting Eorzea weather by time
-rw-r--r--Cargo.lock52
-rw-r--r--Cargo.toml2
-rw-r--r--data/weather_data.json747
-rw-r--r--src/eorzean_weather.rs171
4 files changed, 972 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4bf78e4..cb9bf0c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -69,6 +69,8 @@ name = "ffxiv-chronowatcher"
version = "0.1.0"
dependencies = [
"chrono",
+ "serde",
+ "serde_json",
]
[[package]]
@@ -95,6 +97,12 @@ dependencies = [
]
[[package]]
+name = "itoa"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
+
+[[package]]
name = "js-sys"
version = "0.3.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -116,6 +124,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
+name = "memchr"
+version = "2.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
+
+[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -149,6 +163,44 @@ dependencies = [
]
[[package]]
+name = "ryu"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
+
+[[package]]
+name = "serde"
+version = "1.0.208"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.208"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.125"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed"
+dependencies = [
+ "itoa",
+ "memchr",
+ "ryu",
+ "serde",
+]
+
+[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index e210e37..b4c9dcc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,3 +5,5 @@ edition = "2021"
[dependencies]
chrono = "0.4.38"
+serde = "1.0.208"
+serde_json = "1.0.125"
diff --git a/data/weather_data.json b/data/weather_data.json
new file mode 100644
index 0000000..5af7106
--- /dev/null
+++ b/data/weather_data.json
@@ -0,0 +1,747 @@
+{
+ "Limsa Lominsa": [
+ ["Clouds", 20],
+ ["Clear Skies", 50],
+ ["Fair Skies", 80],
+ ["Fog", 90],
+ ["Rain", 100]
+ ],
+ "Limsa Lominsa Lower Decks": [
+ ["Clouds", 20],
+ ["Clear Skies", 50],
+ ["Fair Skies", 80],
+ ["Fog", 90],
+ ["Rain", 100]
+ ],
+ "Ul'dah": [
+ ["Clear Skies", 40],
+ ["Fair Skies", 60],
+ ["Clouds", 85],
+ ["Fog", 95],
+ ["Rain", 100]
+ ],
+ "Ul'dah - Steps of Thal": [
+ ["Clear Skies", 40],
+ ["Fair Skies", 60],
+ ["Clouds", 85],
+ ["Fog", 95],
+ ["Rain", 100]
+ ],
+ "Gridania": [
+ ["Rain", 5],
+ ["Rain", 20],
+ ["Fog", 30],
+ ["Clouds", 40],
+ ["Fair Skies", 55],
+ ["Clear Skies", 85],
+ ["Fair Skies", 100]
+ ],
+ "Old Gridania": [
+ ["Rain", 5],
+ ["Rain", 20],
+ ["Fog", 30],
+ ["Clouds", 40],
+ ["Fair Skies", 55],
+ ["Clear Skies", 85],
+ ["Fair Skies", 100]
+ ],
+ "Middle La Noscea": [
+ ["Clouds", 20],
+ ["Clear Skies", 50],
+ ["Fair Skies", 70],
+ ["Wind", 80],
+ ["Fog", 90],
+ ["Rain", 100]
+ ],
+ "Lower La Noscea": [
+ ["Clouds", 20],
+ ["Clear Skies", 50],
+ ["Fair Skies", 70],
+ ["Wind", 80],
+ ["Fog", 90],
+ ["Rain", 100]
+ ],
+ "Mist": [
+ ["Clouds", 20],
+ ["Clear Skies", 50],
+ ["Fair Skies", 80],
+ ["Fog", 90],
+ ["Rain", 100]
+ ],
+ "Eastern La Noscea": [
+ ["Fog", 5],
+ ["Clear Skies", 50],
+ ["Fair Skies", 80],
+ ["Clouds", 90],
+ ["Rain", 95],
+ ["Showers", 100]
+ ],
+ "Western La Noscea": [
+ ["Fog", 10],
+ ["Clear Skies", 40],
+ ["Fair Skies", 60],
+ ["Clouds", 80],
+ ["Wind", 90],
+ ["Gales", 100]
+ ],
+ "Upper La Noscea": [
+ ["Clear Skies", 30],
+ ["Fair Skies", 50],
+ ["Clouds", 70],
+ ["Fog", 80],
+ ["Thunder", 90],
+ ["Thunderstorms", 100]
+ ],
+ "Western Thanalan": [
+ ["Clear Skies", 40],
+ ["Fair Skies", 60],
+ ["Clouds", 85],
+ ["Fog", 95],
+ ["Rain", 100]
+ ],
+ "Central Thanalan": [
+ ["Dust Storms", 15],
+ ["Clear Skies", 55],
+ ["Fair Skies", 75],
+ ["Clouds", 85],
+ ["Fog", 95],
+ ["Rain", 100]
+ ],
+ "Eastern Thanalan": [
+ ["Clear Skies", 40],
+ ["Fair Skies", 60],
+ ["Clouds", 70],
+ ["Fog", 80],
+ ["Rain", 85],
+ ["Showers", 100]
+ ],
+ "Southern Thanalan": [
+ ["Heat Waves", 20],
+ ["Clear Skies", 60],
+ ["Fair Skies", 80],
+ ["Clouds", 90],
+ ["Fog", 100]
+ ],
+ "Northern Thanalan": [
+ ["Clear Skies", 5],
+ ["Fair Skies", 20],
+ ["Clouds", 50],
+ ["Fog", 100]
+ ],
+ "Central Shroud": [
+ ["Thunder", 5],
+ ["Rain", 20],
+ ["Fog", 30],
+ ["Clouds", 40],
+ ["Fair Skies", 55],
+ ["Clear Skies", 85],
+ ["Fair Skies", 100]
+ ],
+ "The Feasting Grounds": [
+ ["Fair Skies", 50],
+ ["Rain", 100]
+ ],
+ "East Shroud": [
+ ["Thunder", 5],
+ ["Rain", 20],
+ ["Fog", 30],
+ ["Clouds", 40],
+ ["Fair Skies", 55],
+ ["Clear Skies", 85],
+ ["Fair Skies", 100]
+ ],
+ "South Shroud": [
+ ["Fog", 5],
+ ["Thunderstorms", 10],
+ ["Thunder", 25],
+ ["Fog", 30],
+ ["Clouds", 40],
+ ["Fair Skies", 70],
+ ["Clear Skies", 100]
+ ],
+ "North Shroud": [
+ ["Fog", 5],
+ ["Showers", 10],
+ ["Rain", 25],
+ ["Fog", 30],
+ ["Clouds", 40],
+ ["Fair Skies", 70],
+ ["Clear Skies", 100]
+ ],
+ "Coerthas Central Highlands": [
+ ["Blizzards", 20],
+ ["Snow", 60],
+ ["Fair Skies", 70],
+ ["Clear Skies", 75],
+ ["Clouds", 90],
+ ["Fog", 100]
+ ],
+ "Mor Dhona": [
+ ["Clouds", 15],
+ ["Fog", 30],
+ ["Gloom", 60],
+ ["Clear Skies", 75],
+ ["Fair Skies", 100]
+ ],
+ "Outer La Noscea": [
+ ["Clear Skies", 30],
+ ["Fair Skies", 50],
+ ["Clouds", 70],
+ ["Fog", 85],
+ ["Rain", 100]
+ ],
+ "Command Room": [
+ ["Clouds", 20],
+ ["Clear Skies", 50],
+ ["Fair Skies", 80],
+ ["Fog", 90],
+ ["Rain", 100]
+ ],
+ "Wolves' Den Pier": [
+ ["Clouds", 20],
+ ["Clear Skies", 50],
+ ["Fair Skies", 80],
+ ["Fog", 90],
+ ["Thunderstorms", 100]
+ ],
+ "Mist": [
+ ["Clouds", 20],
+ ["Clear Skies", 50],
+ ["Fair Skies", 70],
+ ["Fair Skies", 80],
+ ["Fog", 90],
+ ["Rain", 100]
+ ],
+ "The Lavender Beds": [
+ ["Clouds", 5],
+ ["Rain", 20],
+ ["Fog", 30],
+ ["Clouds", 40],
+ ["Fair Skies", 55],
+ ["Clear Skies", 85],
+ ["Fair Skies", 100]
+ ],
+ "The Goblet": [
+ ["Clear Skies", 40],
+ ["Fair Skies", 60],
+ ["Clouds", 85],
+ ["Fog", 95],
+ ["Rain", 100]
+ ],
+ "The Weeping Saint": [
+ ["Blizzards", 20],
+ ["Snow", 60],
+ ["Fair Skies", 70],
+ ["Clear Skies", 75],
+ ["Clouds", 90],
+ ["Fog", 100]
+ ],
+ "Coerthas Western Highlands": [
+ ["Blizzards", 20],
+ ["Snow", 60],
+ ["Fair Skies", 70],
+ ["Clear Skies", 75],
+ ["Clouds", 90],
+ ["Fog", 100]
+ ],
+ "The Dravanian Forelands": [
+ ["Clouds", 10],
+ ["Fog", 20],
+ ["Thunder", 30],
+ ["Dust Storms", 40],
+ ["Clear Skies", 70],
+ ["Fair Skies", 100]
+ ],
+ "The Dravanian Hinterlands": [
+ ["Clouds", 10],
+ ["Fog", 20],
+ ["Rain", 30],
+ ["Showers", 40],
+ ["Clear Skies", 70],
+ ["Fair Skies", 100]
+ ],
+ "The Churning Mists": [
+ ["Clouds", 10],
+ ["Gales", 20],
+ ["Umbral Static", 40],
+ ["Clear Skies", 70],
+ ["Fair Skies", 100]
+ ],
+ "The Sea of Clouds": [
+ ["Clear Skies", 30],
+ ["Fair Skies", 60],
+ ["Clouds", 70],
+ ["Fog", 80],
+ ["Wind", 90],
+ ["Umbral Wind", 100]
+ ],
+ "Azys Lla": [
+ ["Fair Skies", 35],
+ ["Clouds", 70],
+ ["Thunder", 100]
+ ],
+ "Ishgard": [
+ ["Snow", 60],
+ ["Fair Skies", 70],
+ ["Clear Skies", 75],
+ ["Clouds", 90],
+ ["Fog", 100]
+ ],
+ "The Pillars": [
+ ["Snow", 60],
+ ["Fair Skies", 70],
+ ["Clear Skies", 75],
+ ["Clouds", 90],
+ ["Fog", 100]
+ ],
+ "Seal Rock": [
+ ["Fog", 15],
+ ["Rain", 40],
+ ["Fair Skies", 100]
+ ],
+ "Idyllshire": [
+ ["Clouds", 10],
+ ["Fog", 20],
+ ["Rain", 30],
+ ["Showers", 40],
+ ["Clear Skies", 70],
+ ["Fair Skies", 100]
+ ],
+ "The Diadem": [
+ ["Fair Skies", 40],
+ ["Fog", 75],
+ ["Wind", 95],
+ ["Umbral Wind", 99],
+ ["Hyperelectricity", 100]
+ ],
+ "The Fields of Glory": [
+ ["Fair Skies", 35],
+ ["Snow", 65],
+ ["Blizzards", 85],
+ ["Fog", 100]
+ ],
+ "The Fringes": [
+ ["Clear Skies", 15],
+ ["Fair Skies", 60],
+ ["Clouds", 80],
+ ["Fog", 90],
+ ["Thunder", 100]
+ ],
+ "The Ruby Sea": [
+ ["Thunder", 10],
+ ["Wind", 20],
+ ["Clouds", 35],
+ ["Fair Skies", 75],
+ ["Clear Skies", 100]
+ ],
+ "Yanxia": [
+ ["Showers", 5],
+ ["Rain", 15],
+ ["Fog", 25],
+ ["Clouds", 40],
+ ["Fair Skies", 80],
+ ["Clear Skies", 100]
+ ],
+ "The Peaks": [
+ ["Clear Skies", 10],
+ ["Fair Skies", 60],
+ ["Clouds", 75],
+ ["Fog", 85],
+ ["Wind", 95],
+ ["Dust Storms", 100]
+ ],
+ "The Lochs": [
+ ["Clear Skies", 20],
+ ["Fair Skies", 60],
+ ["Clouds", 80],
+ ["Fog", 90],
+ ["Thunderstorms", 100]
+ ],
+ "The Azim Steppe": [
+ ["Gales", 5],
+ ["Wind", 10],
+ ["Rain", 17],
+ ["Fog", 25],
+ ["Clouds", 35],
+ ["Fair Skies", 75],
+ ["Clear Skies", 100]
+ ],
+ "Kugane": [
+ ["Rain", 10],
+ ["Fog", 20],
+ ["Clouds", 40],
+ ["Fair Skies", 80],
+ ["Clear Skies", 100]
+ ],
+ "Bokairo Inn": [
+ ["Rain", 10],
+ ["Fog", 20],
+ ["Clouds", 40],
+ ["Fair Skies", 80],
+ ["Clear Skies", 100]
+ ],
+ "Rhalgr's Reach": [
+ ["Clear Skies", 15],
+ ["Fair Skies", 60],
+ ["Clouds", 80],
+ ["Fog", 90],
+ ["Thunder", 100]
+ ],
+ "Shirogane": [
+ ["Rain", 10],
+ ["Fog", 20],
+ ["Clouds", 40],
+ ["Fair Skies", 80],
+ ["Clear Skies", 100]
+ ],
+ "The Diadem": [
+ ["Fair Skies", 30],
+ ["Fog", 60],
+ ["Wind", 90],
+ ["Umbral Wind", 100]
+ ],
+ "The House of the Fierce": [
+ ["Showers", 5],
+ ["Rain", 15],
+ ["Fog", 25],
+ ["Clouds", 40],
+ ["Fair Skies", 80],
+ ["Clear Skies", 100]
+ ],
+ "The Doman Enclave": [
+ ["Showers", 5],
+ ["Rain", 15],
+ ["Fog", 25],
+ ["Clouds", 40],
+ ["Fair Skies", 80],
+ ["Clear Skies", 100]
+ ],
+ "Eureka Anemos": [
+ ["Fair Skies", 30],
+ ["Gales", 60],
+ ["Showers", 90],
+ ["Snow", 100]
+ ],
+ "Eureka Pagos": [
+ ["Fair Skies", 10],
+ ["Fog", 28],
+ ["Heat Waves", 46],
+ ["Snow", 64],
+ ["Thunder", 82],
+ ["Blizzards", 100]
+ ],
+ "Eureka Pyros": [
+ ["Fair Skies", 10],
+ ["Heat Waves", 28],
+ ["Thunder", 46],
+ ["Blizzards", 64],
+ ["Umbral Wind", 82],
+ ["Snow", 100]
+ ],
+ "Lakeland": [
+ ["Clear Skies", 20],
+ ["Fair Skies", 60],
+ ["Clouds", 75],
+ ["Fog", 85],
+ ["Rain", 95],
+ ["Thunderstorms", 100]
+ ],
+ "Kholusia": [
+ ["Gales", 10],
+ ["Rain", 20],
+ ["Fog", 30],
+ ["Clouds", 45],
+ ["Fair Skies", 85],
+ ["Clear Skies", 100]
+ ],
+ "Amh Araeng": [
+ ["Fair Skies", 45],
+ ["Clouds", 60],
+ ["Dust Storms", 70],
+ ["Heat Waves", 80],
+ ["Clear Skies", 100]
+ ],
+ "Il Mheg": [
+ ["Rain", 10],
+ ["Fog", 20],
+ ["Clouds", 35],
+ ["Thunderstorms", 45],
+ ["Clear Skies", 60],
+ ["Fair Skies", 100]
+ ],
+ "The Rak'tika Greatwood": [
+ ["Fog", 10],
+ ["Rain", 20],
+ ["Umbral Wind", 30],
+ ["Clear Skies", 45],
+ ["Fair Skies", 85],
+ ["Clouds", 100]
+ ],
+ "The Tempest": [
+ ["Clouds", 20],
+ ["Fair Skies", 80],
+ ["Clear Skies", 100]
+ ],
+ "The Crystarium": [
+ ["Clear Skies", 20],
+ ["Fair Skies", 60],
+ ["Clouds", 75],
+ ["Fog", 85],
+ ["Rain", 95],
+ ["Thunderstorms", 100]
+ ],
+ "Eulmore": [
+ ["Gales", 10],
+ ["Rain", 20],
+ ["Fog", 30],
+ ["Clouds", 45],
+ ["Fair Skies", 85],
+ ["Clear Skies", 100]
+ ],
+ "Eureka Hydatos": [
+ ["Fair Skies", 12],
+ ["Showers", 34],
+ ["Gloom", 56],
+ ["Thunderstorms", 78],
+ ["Snow", 100]
+ ],
+ "The Pendants Personal Suite": [
+ ["Clear Skies", 20],
+ ["Fair Skies", 60],
+ ["Clouds", 75],
+ ["Fog", 85],
+ ["Rain", 95],
+ ["Thunderstorms", 100]
+ ],
+ "The Firmament": [
+ ["Snow", 60],
+ ["Fair Skies", 70],
+ ["Clear Skies", 75],
+ ["Clouds", 90],
+ ["Fog", 100]
+ ],
+ "Onsal Hakair": [
+ ["Fair Skies", 50],
+ ["Wind", 80],
+ ["Rain", 90],
+ ["Gales", 95],
+ ["Fog", 100]
+ ],
+ "Lyhe Mheg": [
+ ["Clear Skies", 50],
+ ["Fair Skies", 100]
+ ],
+ "The Endeavor": [
+ ["Clouds", 20],
+ ["Clear Skies", 50],
+ ["Fair Skies", 80],
+ ["Fog", 90],
+ ["Rain", 100]
+ ],
+ "Bozjan Southern Front": [
+ ["Fair Skies", 52],
+ ["Rain", 64],
+ ["Wind", 76],
+ ["Thunder", 88],
+ ["Dust Storms", 100]
+ ],
+ "Labyrinthos": [
+ ["Clear Skies", 15],
+ ["Fair Skies", 60],
+ ["Clouds", 85],
+ ["Rain", 100]
+ ],
+ "Thavnair": [
+ ["Fog", 10],
+ ["Rain", 20],
+ ["Showers", 25],
+ ["Clear Skies", 40],
+ ["Fair Skies", 80],
+ ["Clouds", 100]
+ ],
+ "Garlemald": [
+ ["Snow", 45],
+ ["Thunder", 50],
+ ["Rain", 55],
+ ["Fog", 60],
+ ["Clouds", 85],
+ ["Fair Skies", 95],
+ ["Clear Skies", 100]
+ ],
+ "Mare Lamentorum": [
+ ["Umbral Wind", 15],
+ ["Moon Dust", 30],
+ ["Fair Skies", 100]
+ ],
+ "Ultima Thule": [
+ ["Astromagnetic Storms", 15],
+ ["Fair Skies", 85],
+ ["Umbral Wind", 100]
+ ],
+ "Elpis": [
+ ["Clouds", 25],
+ ["Umbral Wind", 40],
+ ["Fair Skies", 85],
+ ["Clear Skies", 100]
+ ],
+ "Old Sharlayan": [
+ ["Clear Skies", 10],
+ ["Fair Skies", 50],
+ ["Clouds", 70],
+ ["Fog", 85],
+ ["Snow", 100]
+ ],
+ "Radz-at-Han": [
+ ["Fog", 10],
+ ["Rain", 25],
+ ["Clear Skies", 40],
+ ["Fair Skies", 80],
+ ["Clouds", 100]
+ ],
+ "Zadnor": [
+ ["Fair Skies", 60],
+ ["Rain", 70],
+ ["Wind", 80],
+ ["Thunder", 90],
+ ["Snow", 100]
+ ],
+ "Empyreum": [
+ ["Snow", 5],
+ ["Fair Skies", 25],
+ ["Clear Skies", 65],
+ ["Clouds", 80],
+ ["Fog", 90],
+ ["Rain", 100]
+ ],
+ "Main Hall": [
+ ["Clear Skies", 10],
+ ["Fair Skies", 50],
+ ["Clouds", 70],
+ ["Fog", 85],
+ ["Snow", 100]
+ ],
+ "Andron": [
+ ["Clear Skies", 10],
+ ["Fair Skies", 50],
+ ["Clouds", 70],
+ ["Fog", 85],
+ ["Snow", 100]
+ ],
+ "Unnamed Island": [
+ ["Clear Skies", 25],
+ ["Fair Skies", 70],
+ ["Clouds", 80],
+ ["Rain", 90],
+ ["Fog", 95],
+ ["Showers", 100]
+ ],
+ "Restricted Archives": [
+ ["Clear Skies", 10],
+ ["Fair Skies", 50],
+ ["Clouds", 70],
+ ["Fog", 85],
+ ["Snow", 100]
+ ],
+ "Elysion": [
+ ["Astromagnetic Storms", 15],
+ ["Fair Skies", 85],
+ ["Umbral Wind", 100]
+ ],
+ "Meghaduta Guest Chambers": [
+ ["Fog", 10],
+ ["Rain", 25],
+ ["Clear Skies", 40],
+ ["Fair Skies", 80],
+ ["Clouds", 100]
+ ],
+ "Senatus": [
+ ["Snow", 45],
+ ["Thunder", 50],
+ ["Rain", 55],
+ ["Fog", 60],
+ ["Clouds", 85],
+ ["Fair Skies", 95],
+ ["Clear Skies", 100]
+ ],
+ "Estinien's Chambers": [
+ ["Fog", 10],
+ ["Rain", 25],
+ ["Clear Skies", 40],
+ ["Fair Skies", 80],
+ ["Clouds", 100]
+ ],
+ "Sunperch": [
+ ["Clear Skies", 40],
+ ["Fair Skies", 80],
+ ["Clouds", 85],
+ ["Fog", 95],
+ ["Rain", 100]
+ ],
+ "Earthen Sky Hideout": [
+ ["Fair Skies", 5],
+ ["Clouds", 25],
+ ["Fog", 40],
+ ["Rain", 45],
+ ["Thunderstorms", 50],
+ ["Umbral Static", 100]
+ ],
+ "Tuliyollal": [
+ ["Clear Skies", 40],
+ ["Fair Skies", 80],
+ ["Clouds", 85],
+ ["Fog", 95],
+ ["Rain", 100]
+ ],
+ "Urqopacha": [
+ ["Clear Skies", 20],
+ ["Fair Skies", 50],
+ ["Clouds", 70],
+ ["Fog", 80],
+ ["Wind", 90],
+ ["Snow", 100]
+ ],
+ "Kozama'uka": [
+ ["Clear Skies", 25],
+ ["Fair Skies", 60],
+ ["Clouds", 75],
+ ["Fog", 85],
+ ["Rain", 95],
+ ["Showers", 100]
+ ],
+ "Yak T'el": [
+ ["Clear Skies", 15],
+ ["Fair Skies", 55],
+ ["Clouds", 70],
+ ["Fog", 85],
+ ["Rain", 100]
+ ],
+ "Shaaloani": [
+ ["Clear Skies", 5],
+ ["Fair Skies", 50],
+ ["Clouds", 70],
+ ["Dust Storms", 85],
+ ["Gales", 100]
+ ],
+ "Heritage Found": [
+ ["Fair Skies", 5],
+ ["Clouds", 25],
+ ["Fog", 40],
+ ["Rain", 45],
+ ["Thunderstorms", 50],
+ ["Umbral Static", 100]
+ ],
+ "Living Memory": [
+ ["Rain", 10],
+ ["Fog", 20],
+ ["Clouds", 40],
+ ["Fair Skies", 100]
+ ],
+ "The For'ard Cabins": [
+ ["Clear Skies", 40],
+ ["Fair Skies", 80],
+ ["Clouds", 85],
+ ["Fog", 95],
+ ["Rain", 100]
+ ]
+ }
+ \ No newline at end of file
diff --git a/src/eorzean_weather.rs b/src/eorzean_weather.rs
index e69de29..e752878 100644
--- a/src/eorzean_weather.rs
+++ b/src/eorzean_weather.rs
@@ -0,0 +1,171 @@
+use chrono::{DateTime,Utc};
+use serde::{Deserialize, Serialize};
+use serde_json::from_str;
+use std::fs;
+
+#[derive(Debug)]
+pub enum Weather{
+ AstroMagneticStorm,
+ Blizzards,
+ ClearSkies,
+ Clouds,
+ DustStorms,
+ FairSkies,
+ Fog,
+ Gales,
+ Gloom,
+ HeatWaves,
+ MoonDust,
+ Rain,
+ Showers,
+ Snow,
+ Thunder,
+ Thunderstorms,
+ UmbralStatic,
+ UmbralWind,
+ Wind
+}
+
+impl Weather{
+ pub fn to_string(&self) -> String{
+ match self{
+ Weather::AstroMagneticStorm => "Astro-Magnetic Storms".to_string(),
+ Weather::Blizzards => "Blizzards".to_string(),
+ Weather::ClearSkies => "Clear Skies".to_string(),
+ Weather::Clouds => "Clouds".to_string(),
+ Weather::DustStorms => "Dust Storms".to_string(),
+ Weather::FairSkies => "Fair Skies".to_string(),
+ Weather::Fog => "Fog".to_string(),
+ Weather::Gales => "Gales".to_string(),
+ Weather::Gloom => "Gloom".to_string(),
+ Weather::HeatWaves => "Heat Waves".to_string(),
+ Weather::MoonDust => "Moon Dust".to_string(),
+ Weather::Rain => "Rain".to_string(),
+ Weather::Showers => "Showers".to_string(),
+ Weather::Snow => "Snow".to_string(),
+ Weather::Thunder => "Thunder".to_string(),
+ Weather::Thunderstorms => "Thunderstorms".to_string(),
+ Weather::UmbralStatic => "Umbral Static".to_string(),
+ Weather::UmbralWind => "Umbral Wind".to_string(),
+ Weather::Wind => "Wind".to_string()
+ }
+ }
+}
+
+fn map_string_to_weather(zone_name: String) -> Weather {
+ match zone_name.as_str() {
+ "Astro-Magnetic Storms" => Weather::AstroMagneticStorm,
+ "Blizzards" => Weather::Blizzards,
+ "Clear Skies" => Weather::ClearSkies,
+ "Clouds" => Weather::Clouds,
+ "Dust Storms" => Weather::DustStorms,
+ "Fair Skies" => Weather::FairSkies,
+ "Fog" => Weather::Fog,
+ "Gales" => Weather::Gales,
+ "Gloom" => Weather::Gloom,
+ "Heat Waves" => Weather::HeatWaves,
+ "Moon Dust" => Weather::MoonDust,
+ "Rain" => Weather::Rain,
+ "Showers" => Weather::Showers,
+ "Snow" => Weather::Snow,
+ "Thunder" => Weather::Thunder,
+ "Thunderstorms" => Weather::Thunderstorms,
+ "Umbral Static" => Weather::UmbralStatic,
+ "Umbral Wind" => Weather::UmbralWind,
+ "Wind" => Weather::Wind,
+ _ => panic!("Invalid weather type")
+ }
+}
+
+pub struct EorzeaWeather{
+ pub start_time: i64,
+ pub end_time: i64,
+ pub zone_name: String,
+ pub weather: Weather
+}
+
+/// Handles i64 and DateTime<Utc> types
+pub trait ToUnixTimestamp {
+ /// Converts the implementing type to a Unix timestamp.
+ ///
+ /// # Returns
+ ///
+ /// An `i64` representing the Unix timestamp
+ fn to_unix_timestamp(&self) -> i64;
+}
+
+impl ToUnixTimestamp for i64 {
+ /// Returns the `i64` value as the Unix timestamp
+ fn to_unix_timestamp(&self) -> i64 {
+ *self
+ }
+}
+
+impl ToUnixTimestamp for DateTime<Utc> {
+ /// Converts `DateTime<Utc>` to a Unix timestamp in milliseconds
+ fn to_unix_timestamp(&self) -> i64 {
+ self.timestamp_millis()
+ }
+}
+
+
+pub fn calculate_forecast_target<T: ToUnixTimestamp>(current_time: T) -> i32 {
+ // Convert the input to a Unix timestamp in seconds
+ let unix_seconds = current_time.to_unix_timestamp() / 1000;
+
+ // Get Eorzea hour for weather start
+ let bell = unix_seconds / 175;
+
+ // Do the magic 'cause for calculations 16:00 is 0, 00:00 is 8 and 08:00 is 16
+ let increment = (bell + 8 - (bell % 8)) % 24;
+
+ // Take Eorzea days since unix epoch
+ let total_days = unix_seconds / 4200;
+ let total_days: u32 = total_days.try_into().unwrap_or(0); // Convert to uint
+
+ // 0x64 = 100
+ let calc_base = total_days * 100 + increment as u32;
+
+ // 0xB = 11
+ let step1 = (calc_base << 11) ^ calc_base;
+ let step2 = (step1 >> 8) ^ step1;
+
+ // 0x64 = 100
+ (step2 % 100) as i32
+}
+
+pub fn get_weather_by_time<T: ToUnixTimestamp>(zone_name: &str, current_time: T) -> Weather {
+ // Load the weather data from the JSON file
+ let weather_data = fs::read_to_string("data/weather_data.json").expect("Unable to read the weather data file");
+ let weather_data: serde_json::Value = serde_json::from_str(&weather_data).expect("Unable to parse the weather data");
+ let zone_data = weather_data
+ .get(zone_name)
+ .and_then(|zone| zone.as_array())
+ .expect(&format!("Unable to find the zone '{}' in the weather data", zone_name));
+
+ // Convert the JSON array to a Vec of (String, i32) tuples
+ let zone_data = zone_data
+ .iter()
+ .map(|entry| {
+ let weather = entry[0].as_str().expect("Invalid weather format").to_string();
+ let chance = entry[1].as_i64().expect("Invalid chance format") as i32;
+ (weather, chance)
+ })
+ .collect::<Vec<(String, i32)>>();
+
+ // Get the current forecast target
+ let epoch = current_time.to_unix_timestamp();
+ let forecast_target = calculate_forecast_target(epoch);
+
+ // Find the weather type that matches the forecast target
+ for (weather, chance) in zone_data {
+ println!("Weather: {}, Chance: {}", weather, chance);
+ if forecast_target < chance {
+ return map_string_to_weather(weather);
+ }
+ }
+
+ // Throw an error if no weather found
+ panic!("No weather found for the forecast target");
+}
+
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage