You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.0KB

  1. use serde::{Serialize, Deserialize};
  2. use chrono_tz::Tz;
  3. use chrono_tz::US::{Eastern, Central, Pacific};
  4. use chrono_tz::Etc::GMTPlus5;
  5. use Market::*;
  6. #[serde(rename_all = "lowercase")]
  7. #[derive(Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Debug)]
  8. #[repr(u8)]
  9. pub enum Market {
  10. Pjm = 1,
  11. Miso = 2,
  12. Caiso = 3,
  13. Ercot = 4,
  14. Spp = 5,
  15. Nyiso = 6,
  16. Iso = 7,
  17. }
  18. impl Market {
  19. pub fn time_zone(&self) -> Tz {
  20. match self {
  21. Pjm => Eastern,
  22. Miso => GMTPlus5,
  23. Caiso => Pacific,
  24. Ercot => Central,
  25. Spp => Central,
  26. Nyiso => Eastern,
  27. Iso => Eastern,
  28. }
  29. }
  30. pub fn as_str(&self) -> &'static str {
  31. match self {
  32. Pjm => "pjm",
  33. Miso => "miso",
  34. Caiso => "caiso",
  35. Ercot => "ercot",
  36. Spp => "spp",
  37. Nyiso => "nyiso",
  38. Iso => "isone",
  39. }
  40. }
  41. }