Skip to content

Commit

Permalink
Merge pull request #15 from mbsoftworks/chrono
Browse files Browse the repository at this point in the history
Disable default features
  • Loading branch information
bombsimon authored Sep 30, 2022
2 parents 5c69fd2 + 0f61cbe commit f01a113
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ homepage = "https://personnummer.dev"
repository = "https://github.com/personnummer/rust"

[dependencies]
chrono = "0.4"
chrono = { version = "0.4", default-features = false, features = [
"clock",
"std",
] }
lazy_static = "1.4.0"
regex = "1"
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,12 @@ impl Personnummer {
pub fn get_age(&self) -> i32 {
let now = Utc::now();

if self.date.month() > now.month() {
if self.date.month() > now.month()
|| self.date.month() == now.month() && self.date.day() > now.day()
{
now.year() - self.date.year() - 1
} else {
if self.date.month() == now.month() && self.date.day() > now.day() {
now.year() - self.date.year() - 1
} else {
now.year() - self.date.year()
}
now.year() - self.date.year()
}
}

Expand Down

0 comments on commit f01a113

Please sign in to comment.