Getting the actual start time of the game.
This commit is contained in:
		
							parent
							
								
									3bbf63132e
								
							
						
					
					
						commit
						b07c4abd88
					
				
							
								
								
									
										247
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										247
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @ -17,6 +17,30 @@ version = "2.0.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "aho-corasick" | ||||
| version = "1.1.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" | ||||
| dependencies = [ | ||||
|  "memchr", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "android-tzdata" | ||||
| version = "0.1.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "android_system_properties" | ||||
| version = "0.1.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" | ||||
| dependencies = [ | ||||
|  "libc", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "atomic-waker" | ||||
| version = "1.1.2" | ||||
| @ -89,6 +113,42 @@ version = "1.0.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "chrono" | ||||
| version = "0.4.40" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" | ||||
| dependencies = [ | ||||
|  "android-tzdata", | ||||
|  "iana-time-zone", | ||||
|  "js-sys", | ||||
|  "num-traits", | ||||
|  "wasm-bindgen", | ||||
|  "windows-link", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "chrono-tz" | ||||
| version = "0.8.6" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "d59ae0466b83e838b81a54256c39d5d7c20b9d7daa10510a242d9b75abd5936e" | ||||
| dependencies = [ | ||||
|  "chrono", | ||||
|  "chrono-tz-build", | ||||
|  "phf", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "chrono-tz-build" | ||||
| version = "0.2.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "433e39f13c9a060046954e0592a8d0a4bcb1040125cbf91cb8ee58964cfb350f" | ||||
| dependencies = [ | ||||
|  "parse-zoneinfo", | ||||
|  "phf", | ||||
|  "phf_codegen", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "colored" | ||||
| version = "3.0.0" | ||||
| @ -414,6 +474,30 @@ dependencies = [ | ||||
|  "tracing", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "iana-time-zone" | ||||
| version = "0.1.63" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" | ||||
| dependencies = [ | ||||
|  "android_system_properties", | ||||
|  "core-foundation-sys", | ||||
|  "iana-time-zone-haiku", | ||||
|  "js-sys", | ||||
|  "log", | ||||
|  "wasm-bindgen", | ||||
|  "windows-core", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "iana-time-zone-haiku" | ||||
| version = "0.1.2" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" | ||||
| dependencies = [ | ||||
|  "cc", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "icu_collections" | ||||
| version = "1.5.0" | ||||
| @ -569,15 +653,6 @@ version = "2.11.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "iso8601" | ||||
| version = "0.6.2" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "c5c177cff824ab21a6f41079a4c401241c4e8be14f316c4c6b07d5fca351c98d" | ||||
| dependencies = [ | ||||
|  "nom", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "itoa" | ||||
| version = "1.0.15" | ||||
| @ -668,12 +743,12 @@ dependencies = [ | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "nom" | ||||
| version = "8.0.0" | ||||
| name = "num-traits" | ||||
| version = "0.2.19" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" | ||||
| checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" | ||||
| dependencies = [ | ||||
|  "memchr", | ||||
|  "autocfg", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| @ -746,12 +821,59 @@ dependencies = [ | ||||
|  "unicode-width", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "parse-zoneinfo" | ||||
| version = "0.3.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24" | ||||
| dependencies = [ | ||||
|  "regex", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "percent-encoding" | ||||
| version = "2.3.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "phf" | ||||
| version = "0.11.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" | ||||
| dependencies = [ | ||||
|  "phf_shared", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "phf_codegen" | ||||
| version = "0.11.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" | ||||
| dependencies = [ | ||||
|  "phf_generator", | ||||
|  "phf_shared", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "phf_generator" | ||||
| version = "0.11.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" | ||||
| dependencies = [ | ||||
|  "phf_shared", | ||||
|  "rand", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "phf_shared" | ||||
| version = "0.11.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" | ||||
| dependencies = [ | ||||
|  "siphasher", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "pin-project-lite" | ||||
| version = "0.2.16" | ||||
| @ -829,8 +951,9 @@ dependencies = [ | ||||
| name = "pulse" | ||||
| version = "0.1.0" | ||||
| dependencies = [ | ||||
|  "chrono", | ||||
|  "chrono-tz", | ||||
|  "colored", | ||||
|  "iso8601", | ||||
|  "reqwest", | ||||
|  "serde", | ||||
|  "serde_alias", | ||||
| @ -853,6 +976,50 @@ version = "5.2.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "rand" | ||||
| version = "0.8.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" | ||||
| dependencies = [ | ||||
|  "rand_core", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "rand_core" | ||||
| version = "0.6.4" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "regex" | ||||
| version = "1.11.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" | ||||
| dependencies = [ | ||||
|  "aho-corasick", | ||||
|  "memchr", | ||||
|  "regex-automata", | ||||
|  "regex-syntax", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "regex-automata" | ||||
| version = "0.4.9" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" | ||||
| dependencies = [ | ||||
|  "aho-corasick", | ||||
|  "memchr", | ||||
|  "regex-syntax", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "regex-syntax" | ||||
| version = "0.8.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "reqwest" | ||||
| version = "0.12.15" | ||||
| @ -1077,6 +1244,12 @@ version = "1.3.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "siphasher" | ||||
| version = "1.0.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "slab" | ||||
| version = "0.4.9" | ||||
| @ -1481,6 +1654,41 @@ dependencies = [ | ||||
|  "wasm-bindgen", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows-core" | ||||
| version = "0.61.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" | ||||
| dependencies = [ | ||||
|  "windows-implement", | ||||
|  "windows-interface", | ||||
|  "windows-link", | ||||
|  "windows-result", | ||||
|  "windows-strings 0.4.0", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows-implement" | ||||
| version = "0.60.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" | ||||
| dependencies = [ | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  "syn 2.0.100", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows-interface" | ||||
| version = "0.59.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" | ||||
| dependencies = [ | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  "syn 2.0.100", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows-link" | ||||
| version = "0.1.1" | ||||
| @ -1494,7 +1702,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" | ||||
| dependencies = [ | ||||
|  "windows-result", | ||||
|  "windows-strings", | ||||
|  "windows-strings 0.3.1", | ||||
|  "windows-targets 0.53.0", | ||||
| ] | ||||
| 
 | ||||
| @ -1516,6 +1724,15 @@ dependencies = [ | ||||
|  "windows-link", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows-strings" | ||||
| version = "0.4.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" | ||||
| dependencies = [ | ||||
|  "windows-link", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows-sys" | ||||
| version = "0.52.0" | ||||
|  | ||||
| @ -5,9 +5,10 @@ edition = "2024" | ||||
| 
 | ||||
| [dependencies] | ||||
| colored = "3.0.0" | ||||
| iso8601 = "0.6.2" | ||||
| reqwest = { version = "0.12.15", features = ["blocking"] } | ||||
| serde = {version = "1.0.219", features = ["derive"]} | ||||
| serde_alias = "0.0.2" | ||||
| serde_json = "1.0.140" | ||||
| tabled = "0.18.0" | ||||
| chrono = "0.4" | ||||
| chrono-tz = "0.8" | ||||
|  | ||||
| @ -43,8 +43,13 @@ fn main() { | ||||
|         // Check if there is a sox game and print opp.
 | ||||
|         for sox_game in &sox_games { | ||||
|             if sox_game.date == yyyy_mm_dd { | ||||
|                 // @todo - currently hardcoding time - figure out how to get it.
 | ||||
|                 sox_status = format!("{} {}\n{} {}", baseball_icon, &sox_game.opponent, clock_icon, "8:00".to_string()); | ||||
|                 sox_status = format!( | ||||
|                     "{} {}\n{} {}", | ||||
|                     &baseball_icon, | ||||
|                     &sox_game.opponent, | ||||
|                     &clock_icon, 
 | ||||
|                     &sox_game.start_time, | ||||
|                 ); | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| use serde::{Deserialize, Serialize}; | ||||
| use serde_alias::serde_alias; | ||||
| // use iso8601;
 | ||||
| use chrono::{DateTime, Utc}; | ||||
| use chrono_tz::US::Eastern; | ||||
| 
 | ||||
| const TEAM_ID: i32 = 111; | ||||
| 
 | ||||
| @ -24,7 +25,7 @@ pub struct Game { | ||||
|     pub teams: Teams, | ||||
|     // pub date: String,
 | ||||
|     pub official_date: String, | ||||
|     // pub start_time: String,
 | ||||
|     pub game_date: String, | ||||
|     // pub opponent: String,
 | ||||
| } | ||||
| 
 | ||||
| @ -59,7 +60,7 @@ pub struct TeamRecord { | ||||
| pub struct GameInfo { | ||||
|     pub opponent: String, | ||||
|     pub date: String, | ||||
|     // pub time: String,
 | ||||
|     pub start_time: String, | ||||
| } | ||||
| 
 | ||||
| // Gets the full forecast from the response.
 | ||||
| @ -76,6 +77,7 @@ pub fn get_schedule() -> Vec<GameInfo> { | ||||
|             let game_info = GameInfo { | ||||
|                 opponent: facing, | ||||
|                 date: game.official_date, | ||||
|                 start_time: get_start_time(&game.game_date), | ||||
|             }; | ||||
|             full_schedule.push(game_info); | ||||
|         } | ||||
| @ -100,6 +102,12 @@ fn build_api_url() -> String { | ||||
|     format!("{}{}{}", url_first, TEAM_ID, url_second) | ||||
| } | ||||
| 
 | ||||
| fn get_start_time(iso_string: &String) -> String { | ||||
|     let utc_dt: DateTime<Utc> = iso_string.parse().expect("Invalid ISO8601 string"); | ||||
|     let est_dt = utc_dt.with_timezone(&Eastern); | ||||
|     est_dt.format("%I:%M").to_string() | ||||
| } | ||||
| 
 | ||||
| #[cfg(test)] | ||||
| mod team_tests { | ||||
|     use super::*; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 calcu1on
						calcu1on