Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Handles validation of Swedish personal identity numbers.
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
Changelog
Gemfile
Gemfile.lock
Guardfile
LICENSE
README.markdown
Rakefile
demo.rb
personnummer.gemspec

README.markdown

Personnummer

Personnummer is a ruby class that handles Swedish personal identity number.

Installation

$ gem install personnummer

Example usage

>> p = Personnummer.new('830428-5912')
#>>Personnummer:0x007fc971369100 @valid=true, @control_digit=2, @divider="-", @serial=591, @born=#>>PersonnummerDate:0x007fc971368318 @divider="-", @day=28, @month=4, @year=1983> #<, @region="Skaraborgs län", @female=false> #<

>> p.valid?
=> true

This implementation also supports co-ordination numbers

Information about co-ordination numbers (in swedish)

These numbers are obtained by adding 60 to the day of the birth date

>> p = Personnummer.new('830488-5912')
=> #<Personnummer:0x007fbafd1458d8 ...>
>> p.born
=> #<Date: 1983-04-28 ((2445453j,0s,0n),+0s,2299161j)>
>> p.co_ordination_number?
=> true
Something went wrong with that request. Please try again.