Browse Source

initial commit

tags/v0.2.0
Jonathan Strong 4 years ago
commit
770e2c72c0
3 changed files with 69 additions and 0 deletions
  1. +3
    -0
      .gitignore
  2. +14
    -0
      Cargo.toml
  3. +52
    -0
      src/lib.rs

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
/target
Cargo.lock
*.swp

+ 14
- 0
Cargo.toml View File

@@ -0,0 +1,14 @@
[package]
name = "markets"
version = "0.1.0"
authors = ["Jonathan Strong <jstrong@tioscapital.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1", features = ["derive"] }
chrono = { version = "0.4", features = ["serde"] }
chrono-tz = "0.4"
uuid = { version = "0.7.0", features = ["serde", "v4", "slog"] }
hashbrown = { version = "0.6.3", default_features = false, features = ["serde", "ahash"] }

+ 52
- 0
src/lib.rs View File

@@ -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);
}
}

Loading…
Cancel
Save