eXparity / hamcrest-date

A Java library which provides a suite hamcrest matchers for matching dates, times, and moments in time
BSD 3-Clause "New" or "Revised" License
70 stars 11 forks source link

Current date matchers #5

Closed Proximator closed 11 years ago

Proximator commented 11 years ago

Hi stewbis,

I think it would be useful to have a matchers based on the current date (CurrentDateMatchers) containing for example beforeCurrentDate // assertThat(date1, beforeCurrentDate() ) means date1 is before new Date() beforeCurrentHour beforeCurrentMinute...etc beforeCurrentTime afterCurrentDate afterCurrentHour...etc

What do you think ?

Regards

stewbis commented 11 years ago

In this instance I think the existing assertThat(date, before(new Date())) is fine and IMHO reads cleaner than assertThat(date, beforeToday()), Part of the library could provide static factories for commonly used date constructs e.g Dates.today(), Dates.tomorow(), etc. This would allow assertThat(date, before(today()));

stewbis commented 11 years ago

Added Moments static factory to allow syntax of:

assertThat(date, DateMatchers.before(Moments.today()));