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.

53 lines
1.1KB

  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. #[derive(Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
  7. #[repr(u8)]
  8. pub enum Market {
  9. Pjm = 1,
  10. Miso = 2,
  11. Caiso = 3,
  12. Ercot = 4,
  13. Spp = 5,
  14. Nyiso = 6,
  15. Iso = 7,
  16. }
  17. impl Market {
  18. pub fn time_zone(&self) -> Tz {
  19. match self {
  20. Pjm => Eastern,
  21. Miso => GMTPlus5,
  22. Caiso => Pacific,
  23. Ercot => Central,
  24. Spp => Central,
  25. Nyiso => Eastern,
  26. Iso => Eastern,
  27. }
  28. }
  29. pub fn as_str(&self) -> &'static str {
  30. match self {
  31. Pjm => "pjm",
  32. Miso => "miso",
  33. Caiso => "caiso",
  34. Ercot => "ercot",
  35. Spp => "spp",
  36. Nyiso => "nyiso",
  37. Iso => "isone",
  38. }
  39. }
  40. }
  41. #[cfg(test)]
  42. mod tests {
  43. #[test]
  44. fn it_works() {
  45. assert_eq!(2 + 2, 4);
  46. }
  47. }