def initialize(date)
date = date.to_s if date.respond_to? :to_s
if date =~ /^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/
@year = $1.to_i
@month = $2 ? $2.to_i : nil
@day = $3 ? $3.to_i : nil
if @month
if @day
start_d = Date.civil( @year, @month, @day)
end_d = start_d
else
start_d = Date.civil( @year, @month)
end_d = Date.civil( @year, @month, -1)
end
else
start_d = Date.civil( @year)
end_d = Date.civil( @year, -1, -1)
end
super( start_d, end_d)
else
raise ArgumentError, "Invalid incomplete date #{date}"
end
end