Class | MusicBrainz::Model::IncompleteDate |
In: |
lib/rbrainz/model/incomplete_date.rb
|
Parent: | ::Range |
Represents an incomplete date. An incomplete date is a date which can be defined without day or without month and day. It can be written as YYYY, YYYY-MM or YYYY-MM-DD.
An IncompleteDate is a Range of Date objects. The incomplete date 1969-01 for example results in a range beginning on 1969-01-01 and ending on 1969-01-31, including the end.
RBrainz extends the Ruby Range class with additional comparison methods. See CoreExtensions::Range::Equality for a description of those methods.
day | [R] | |
month | [R] | |
year | [R] |
Create a new IncompleteDate. The parameter date must be a String in the form YYYY, YYYY-MM or YYYY-MM-DD.
Compare two IncompleteDate objects for equality.
You can compare an IncompleteDate with another IncompleteDate, with a Range of Date objects or directly with a Date. The following examples all return true:
IncompleteDate.new('1969-01-05').eql?( IncompleteDate.new('1969-01-05') ) IncompleteDate.new('1969-01-05').eql?( Date.civil(1969, 1, 5) ) IncompleteDate.new('1969-01').eql?( Date.civil(1969, 1)..Date.civil(1969, 1, 31) ) IncompleteDate.new('1969-01').eql?( Date.civil(1969, 1)...Date.civil(1969, 2, 1) )
Please note that comparing an IncompleteDate with something else than a IncompleteDate is normally not symmetric.
Returns true if b is completely included in this IncompleteDate. Unlike CoreExtensions::Range::Equality#contains? include? allows equality for begin and end.