Changeset 11639 in josm


Ignore:
Timestamp:
2017-02-26T23:10:22+01:00 (2 years ago)
Author:
stoecker
Message:

support strange ELI end date definition as well

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/SyncEditorLayerIndex.groovy

    r11612 r11639  
    313313            // The forms 2015;- or -;2015 or 2015;2015 are handled equal to 2015
    314314            String ef = ed.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1");
    315             if (!ed.equals(jd) && !ef.equals(jd)) {
     315            // ELI has a strange and inconsistent used end_date definition, so we try again with subtraction by one
     316            String ed2 = ed;
     317            def reg = (ed =~ /^(.*;)(\d\d\d\d)(-(\d\d)(-(\d\d))?)?$/)
     318            if(reg != null && reg.count == 1) {
     319                Calendar cal = Calendar.getInstance();
     320                cal.set(reg[0][2] as Integer, reg[0][4] == null ? 0 : (reg[0][4] as Integer)-1, reg[0][6] == null ? 1 : reg[0][6] as Integer)
     321                cal.add(Calendar.DAY_OF_MONTH, -1)
     322                ed2 = cal.get(Calendar.YEAR)
     323                if (reg[0][4] != null)
     324                    ed2 += "-" + String.format("%02d", cal.get(Calendar.MONTH)+1)
     325                if (reg[0][6] != null)
     326                    ed2 += "-" + String.format("%02d", cal.get(Calendar.DAY_OF_MONTH))
     327            }
     328            String ef2 = ed2.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1");
     329            if (!ed.equals(jd) && !ef.equals(jd) && !ed2.equals(jd) && !ef2.equals(jd)) {
    316330                String t = "'${ed}'";
    317331                if (!ed.equals(ef)) {
    318                     t += "or '${ef}'";
     332                    t += " or '${ef}'";
    319333                }
    320334                myprintln "* Date differs (${t} != '${jd}'): ${getDescription(j)}"
     
    416430            def d = getDate(j)
    417431            if(!d.isEmpty()) {
    418                 def reg = (d =~ /^(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?)(;(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?))?/)
     432                def reg = (d =~ /^(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?)(;(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?))?$/)
    419433                if(reg == null || reg.count != 1) {
    420434                    myprintln "* JOSM-Date '${d}' is strange: ${getDescription(j)}"
Note: See TracChangeset for help on using the changeset viewer.