|
|
@@ -0,0 +1,52 @@ |
|
|
|
use serde::{Serialize, Deserialize}; |
|
|
|
use chrono_tz::Tz; |
|
|
|
use chrono_tz::US::{Eastern, Central, Pacific}; |
|
|
|
use chrono_tz::Etc::GMTPlus5; |
|
|
|
|
|
|
|
use Market::*; |
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] |
|
|
|
#[repr(u8)] |
|
|
|
pub enum Market { |
|
|
|
Pjm = 1, |
|
|
|
Miso = 2, |
|
|
|
Caiso = 3, |
|
|
|
Ercot = 4, |
|
|
|
Spp = 5, |
|
|
|
Nyiso = 6, |
|
|
|
Iso = 7, |
|
|
|
} |
|
|
|
|
|
|
|
impl Market { |
|
|
|
pub fn time_zone(&self) -> Tz { |
|
|
|
match self { |
|
|
|
Pjm => Eastern, |
|
|
|
Miso => GMTPlus5, |
|
|
|
Caiso => Pacific, |
|
|
|
Ercot => Central, |
|
|
|
Spp => Central, |
|
|
|
Nyiso => Eastern, |
|
|
|
Iso => Eastern, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
pub fn as_str(&self) -> &'static str { |
|
|
|
match self { |
|
|
|
Pjm => "pjm", |
|
|
|
Miso => "miso", |
|
|
|
Caiso => "caiso", |
|
|
|
Ercot => "ercot", |
|
|
|
Spp => "spp", |
|
|
|
Nyiso => "nyiso", |
|
|
|
Iso => "isone", |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#[cfg(test)] |
|
|
|
mod tests { |
|
|
|
#[test] |
|
|
|
fn it_works() { |
|
|
|
assert_eq!(2 + 2, 4); |
|
|
|
} |
|
|
|
} |