edits.seer.internal.contexts.compareDatesWithinMonths.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of validation-edits-seer Show documentation
Show all versions of validation-edits-seer Show documentation
Java implemenation of the SEER edits.
<entry id="compareDatesWithinMonths" type="groovy"><![CDATA[// this closure is used to compare two dates and see if the first date is within monthsInterval months of the second date return { Integer year1, Integer month1, Integer day1, Integer year2, Integer month2, Integer day2, Integer monthsInterval -> int interval = monthsInterval == null ? 0 : monthsInterval int y1 = year1 == null ? 9999 : year1 int m1 = month1 == null ? 99 : month1 int d1 = day1 == null ? 99 : day1 int y2 = year2 == null ? 9999 : year2 int m2 = month2 == null ? 99 : month2 + interval int d2 = day2 == null ? 99 : day2 if (m2 > 12 && m2 != 99) { y2 = y2 == null ? 9999 : y2 + (m2 / 12) m2 = m2 % 12 } if (y1 == 9999 || y2 == 9999) return true if (y1 != y2) return y1 < y2 if (m1 == 99 || m2 == 99) return true if (m1 != m2) return m1 < m2 if (d1 == 99 || d2 == 99) return true return d1 <= d2 }]]></entry>