kennitala 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/Gemfile.lock +1 -1
- data/lib/kennitala.rb +17 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8792edca881857efe4e1c11478d824647b9ec0ae1a1cfadef0f90186b573774
|
4
|
+
data.tar.gz: 2116570f2dc96220c2202d0dee1f73033dd47155c64b3c2ec31775ca632fe7a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b111102355338dbbfdf61952067487758ce09aa878109f5bdad82567564a44263c24aef1c02ee15409ca0f8e3ed5f5b179f5000e860bffd66ae5ba922ab0141
|
7
|
+
data.tar.gz: 22b07a7a3af1b56d4f9094fb6fd6c356b28ecfb73f88de2dff4d98e671989397aeca3b3292354b0a557b3cf177e6a99ebd87087b04073d8b29f176a023ddb2bc
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/kennitala.rb
CHANGED
@@ -6,7 +6,7 @@ require_relative 'kennitala_string'
|
|
6
6
|
# The main Kennitala class
|
7
7
|
class Kennitala
|
8
8
|
# The current version of the gem
|
9
|
-
VERSION = '0.1.
|
9
|
+
VERSION = '0.1.2'
|
10
10
|
|
11
11
|
# Initialize a Kennitala object
|
12
12
|
#
|
@@ -90,9 +90,19 @@ class Kennitala
|
|
90
90
|
#
|
91
91
|
# @return [Fixnum]
|
92
92
|
def day
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
day_from_value = @value[0, 2].to_s[0, 2].to_i
|
94
|
+
day_from_value -= 40 if day_from_value > 40
|
95
|
+
|
96
|
+
# There are examples of a date overlapping the number of days in the
|
97
|
+
# given month. Those are considered to be from the last day of that month
|
98
|
+
# instad of the specified out-of-bounds day of the month.
|
99
|
+
# This is common for the year 1969 as new registrations were being done en
|
100
|
+
# masse.
|
101
|
+
last_day_of_month = Date.new(year, month, -1).day
|
102
|
+
|
103
|
+
return last_day_of_month if day_from_value > last_day_of_month
|
104
|
+
|
105
|
+
day_from_value
|
96
106
|
end
|
97
107
|
|
98
108
|
# Get a numeric representation of the month of birth or registration
|
@@ -252,6 +262,9 @@ class Kennitala
|
|
252
262
|
day = sanitized_kt[0, 2].to_i
|
253
263
|
day -= 40 if day > 40
|
254
264
|
month = sanitized_kt[2, 2].to_i
|
265
|
+
|
266
|
+
last_day_of_month = Date.new(year, month, -1).day
|
267
|
+
day = last_day_of_month if day > last_day_of_month
|
255
268
|
date = Date.new(year, month, day)
|
256
269
|
|
257
270
|
return sanitized_kt if checks == true && date.instance_of?(Date)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kennitala
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alda Vigdís Skarphéðinsdóttir
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|