diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-12-26 23:06:46 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-12-26 23:06:46 +0100 |
commit | ae2c49a315e48dc16dce28a12f215c50f20e9324 (patch) | |
tree | d34a977d78f65528d43d48e3ba7eea02cc0ed41b /src/lib.rs | |
parent | bd1d3827f1a0f36d78c48e714d8a0214d53c479f (diff) | |
download | primstav-ae2c49a315e48dc16dce28a12f215c50f20e9324.tar.gz primstav-ae2c49a315e48dc16dce28a12f215c50f20e9324.tar.bz2 primstav-ae2c49a315e48dc16dce28a12f215c50f20e9324.zip |
Move more functionality to lib.
Add a constructor for initializing the Primstav object, and a method
to get the entry for a given date if the entry exists.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -28,3 +28,15 @@ pub struct Mark { pub struct Primstav { pub marks: BTreeMap<String, Mark>, } + +impl Primstav { + pub fn new(marks: BTreeMap<String, Mark>) -> Primstav { + Primstav { marks } + } + + /// Get an entry for the given date if one exists. + pub fn get(&self, date: &chrono::NaiveDate) -> Option<&Mark> { + let key = date.format("%d%m").to_string(); + self.marks.get(&key) + } +} |