Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Fixes:
- Fix Finland checks for tins ending in `P` 🇫🇮
- Fix Denmark check for certain ranges of birth years 🇩🇰

## [1.2.1] - 2025-05-22

Expand Down
7 changes: 4 additions & 3 deletions lib/tin_valid/denmark_tin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@ def checksum
# rubocop:disable Metrics/PerceivedComplexity
def check_serial(serial, year)
case serial.to_i
in 1..3999
when 1..3999
(1900..1999).cover?(birth_year)
in 4000..4999, 9000..9999
when 4000..4999,
9000..9999
case year.to_i
in 0..36 then (2000..2036).cover?(birth_year)
in 36..99 then (1937..1999).cover?(birth_year)
end
in 5000..8999
when 5000..8999
case year.to_i
in 0..36 then (2000..2036).cover?(birth_year)
in 37..57 then false
Expand Down
2 changes: 2 additions & 0 deletions spec/tin_valid/denmark_tin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
valid_values = [
["0101111113", nil],
["0101111113", Date.new(1911, 1, 1)],
["2808784028", nil],
["2808784028", Date.new(1978, 8, 28)],
]

invalid_values = [
Expand Down
Loading