Birthday decoding broken in 0.2.0
m1foley opened this issue · 2 comments
m1foley commented
This script works with the previous version of the gem:
gem 'vcard', '=0.1.1'
require 'vcard'
vcard = Vpim::Vcard::Maker.make2 do |maker|
maker.add_name{ |name| name.given = 'Given Name' }
maker.birthday = Date.new(1980, 10, 25)
end
puts vcard
puts vcard.birthday
$ ruby vcard_bday.rb
BEGIN:VCARD
VERSION:3.0
N:;Given Name;;;
FN:Given Name
BDAY:19801025
END:VCARD
1980-10-25
But the birthday parsing breaks in the 0.2.0 version:
gem 'vcard', '=0.2.0'
require 'vcard'
vcard = Vcard::Vcard::Maker.make2 do |maker|
maker.add_name{ |name| name.given = 'Given Name' }
maker.birthday = Date.new(1980, 10, 25)
end
puts vcard
puts vcard.birthday
$ ruby vcard_bday.rb
BEGIN:VCARD
VERSION:3.0
N:;Given Name;;;
FN:Given Name
BDAY:19801025
END:VCARD
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/vcard-0.2.0/lib/vcard.rb:58:in `decode_date': uninitialized constant Vcard::Vcard::InvalidEncodingError (NameError)
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/vcard-0.2.0/lib/vcard.rb:65:in `decode_date_to_date'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/vcard-0.2.0/lib/vcard/vcard.rb:435:in `decode_date_or_datetime'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/vcard-0.2.0/lib/vcard/vcard.rb:444:in `decode_bday'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/vcard-0.2.0/lib/vcard/vcard.rb:565:in `decode'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/vcard-0.2.0/lib/vcard/vcard.rb:743:in `value'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/vcard-0.2.0/lib/vcard/vcard.rb:790:in `birthday'
from vcard_bday.rb:8:in `<main>'
qoobaa commented
I've added your case to test suite. There's something wrong when it comes to parsing dates. I've no time currently to investigate. If you do, please create a pull request.