All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edits.seer.internal.contexts.compareDatesWithinMonths.xml Maven / Gradle / Ivy

There is a newer version: 024-13
Show newest version
<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>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy