From 976e3cc41f90f343922513efbd7d737de62d649f Mon Sep 17 00:00:00 2001 From: Markus Bergkvist Date: Wed, 21 Sep 2022 11:47:13 +0200 Subject: [PATCH] Expose the parts of the personal identity number --- src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 76e6019..4d6fde8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -207,6 +207,26 @@ impl Personnummer { pub fn is_coordination_number(&self) -> bool { self.coordination } + + /// Year of date of birth. + pub fn year(&self) -> i32 { + self.date.year() + } + + /// Month of date of birth. + pub fn month(&self) -> u32 { + self.date.month() + } + + /// Day of date of birth. + pub fn day(&self) -> u32 { + self.date.day() + } + + /// Serial part of personal identity number. + pub fn serial(&self) -> u32 { + self.serial + } } /// Calculate the checksum based on luhn algorithm. See more information here: