Calculate last day of month correctly. refs #14

This commit is contained in:
Mathias Gawlista
2013-01-24 14:18:38 +01:00
parent abd67818d3
commit 4b17499bb4
2 changed files with 54 additions and 5 deletions
+9 -5
View File
@@ -46,14 +46,18 @@ module MusicBrainz
elsif type == String
val.to_s
elsif type == Date
if val.nil? or val == ""
val = "2030-12-31"
val = if val.nil? or val == ""
[2030, 12, 31]
elsif val.split("-").length == 1
val << "-12-31"
[val.split("-").first.to_i, 12, 31]
elsif val.split("-").length == 2
val << "-31"
val = val.split("-").map(&:to_i)
[val.first, val.last, -1]
else
val.split("-").map(&:to_i)
end
Date.new(*val.split(?-).map(&:to_i))
Date.new(*val)
else
val
end