Runt: Matching the year

I downloaded runt to do some temporal expression work, and
was wondering if there's any way to match against a year.
From what I can tell I can match against month, day, hour,
min, sec, but not the year.

Well, strictly speaking you could use a DateRange constructed
with January 1st and December 31st of the year(s) in question but this
is a pain...

Basically I'd like to have a timex that matches all dates
with the year 2005. If I create a date that has the year
2006, then include?
should return false for that particular date. Am I missing
something in the docs? I'd appreciate any help.

Pat

I've just added the following class to CVS (apologize if Outlook mangles
the layout)

# Simple expression which returns true if the supplied arguments
# occur within the given year.

···

#
class YearTE

  def initialize(year)
    @year = year
  end

  def include?(date)
    return date.year == @year
  end

end

For an example of usage see the test case in
test/temporalexpressiontest.rb. Here's an excerpt:

def test_year_te

  # second sun of any month
  second_sun = DIMonth.new(Second, Sunday)

  # simple year matching expression which will return true for
  # any date in 2005
  year_te = YearTE.new(2005)

  # Second Sunday of a month in 2002
  dt_in_2002 = Date.civil(2002,9,8)

  # Second Sunday of a month in 2005
  dt_in_2005 = Date.civil(2005,12,11)

  # Matches
  assert(year_te.include?(dt_in_2005))

  # Does not match
  assert(!year_te.include?(dt_in_2002))
end

Feel free to contact me directly if you have any questions or problems.

Thanks for using Runt!

Matt