Changeset 17747 in josm
- Timestamp:
- 2021-04-11T21:56:45+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r17746 r17747 50 50 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 51 51 import org.openstreetmap.josm.tools.AlphanumComparator; 52 import org.openstreetmap.josm.tools.CheckParameterUtil; 52 53 import org.openstreetmap.josm.tools.Geometry; 53 54 import org.openstreetmap.josm.tools.Logging; … … 195 196 return new KeyValue(keyword, rangeS.trim(), regexSearch, caseSensitive); 196 197 } else if (rangeA.length == 2) { 197 String rangeA1 = rangeA[0].trim(); 198 String rangeA2 = rangeA[1].trim(); 199 final long minDate; 200 final long maxDate; 201 try { 202 // if min timestamp is empty: use lowest possible date 203 minDate = DateUtils.fromString(rangeA1.isEmpty() ? "1980" : rangeA1).getTime(); 204 } catch (UncheckedParseException | DateTimeException ex) { 205 throw new SearchParseError(tr("Cannot parse timestamp ''{0}''", rangeA1), ex); 206 } 207 try { 208 // if max timestamp is empty: use "now" 209 maxDate = rangeA2.isEmpty() ? System.currentTimeMillis() : DateUtils.fromString(rangeA2).getTime(); 210 } catch (UncheckedParseException | DateTimeException ex) { 211 throw new SearchParseError(tr("Cannot parse timestamp ''{0}''", rangeA2), ex); 212 } 213 return new TimestampRange(minDate, maxDate); 198 return TimestampRange.create(rangeA); 214 199 } else { 215 200 throw new SearchParseError("<html>" + tr("Expecting {0} after {1}", "<i>min</i>/<i>max</i>", "<i>timestamp</i>") … … 1500 1485 } 1501 1486 1487 private static TimestampRange create(String[] range) throws SearchParseError { 1488 CheckParameterUtil.ensureThat(range.length == 2, "length 2"); 1489 String rangeA1 = range[0].trim(); 1490 String rangeA2 = range[1].trim(); 1491 final long minDate; 1492 final long maxDate; 1493 try { 1494 // if min timestamp is empty: use lowest possible date 1495 minDate = DateUtils.fromString(rangeA1.isEmpty() ? "1980" : rangeA1).getTime(); 1496 } catch (UncheckedParseException | DateTimeException ex) { 1497 throw new SearchParseError(tr("Cannot parse timestamp ''{0}''", rangeA1), ex); 1498 } 1499 try { 1500 // if max timestamp is empty: use "now" 1501 maxDate = rangeA2.isEmpty() ? System.currentTimeMillis() : DateUtils.fromString(rangeA2).getTime(); 1502 } catch (UncheckedParseException | DateTimeException ex) { 1503 throw new SearchParseError(tr("Cannot parse timestamp ''{0}''", rangeA2), ex); 1504 } 1505 return new TimestampRange(minDate, maxDate); 1506 } 1507 1502 1508 @Override 1503 1509 protected Long getNumber(OsmPrimitive osm) {
Note:
See TracChangeset
for help on using the changeset viewer.