Changeset 6420 in josm
- Timestamp:
- 2013-11-28T18:51:43+01:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/opening_hours.js
r6370 r6420 1102 1102 weekday: 'Mo-Fr', 1103 1103 weekdays: 'Mo-Fr', 1104 }, 'Please ommit "<ko>" or use a colon instead: "12:00-14:00".': { 1105 h: '', 1104 1106 }, 'Please ommit "<ko>".': { 1105 h: '',1106 1107 season: '', 1107 1108 }, 'Please ommit "<ko>". You might want to express open end which can be specified as "12:00+" for example': { 1108 1109 from: '', 1110 }, 'Please use notation "<ok>" for "<ko>". If the times are unsure or variate consider a comment e.g. 12:00-14:00 "only on sunshine".': { 1111 '~': '-', 1109 1112 }, 'Please use notation "<ok>" for "<ko>".': { 1110 1113 '–': '-', … … 1155 1158 nov: 10, 1156 1159 dec: 11, 1157 }, 'Please use the englisch abbreviation "<ok>" for "<ko>".': {1160 }, 'Please use the English abbreviation "<ok>" for "<ko>".': { 1158 1161 january: 0, 1159 1162 february: 1, … … 1215 1218 fr: 5, 1216 1219 sa: 6, 1220 }, 'Assuming "<ok>" for "<ko>"': { 1221 m: 1, 1222 w: 3, 1223 f: 5, 1217 1224 }, 'Please use the abbreviation "<ok>" for "<ko>".': { 1218 1225 sun: 0, 1219 1226 sunday: 0, 1220 1227 sundays: 0, 1221 m: 1,1222 1228 mon: 1, 1223 1229 monday: 1, … … 1226 1232 tuesday: 2, 1227 1233 tuesdays: 2, 1228 w: 3,1229 1234 wed: 3, 1230 1235 wednesday: 3, … … 1233 1238 thursday: 4, 1234 1239 thursdays: 4, 1235 f: 5,1236 1240 fri: 5, 1237 1241 friday: 5, … … 1240 1244 saturday: 6, 1241 1245 saturdays: 6, 1246 }, 'Bitte benutze die englische Abkürzung "<ok>" für "<ko>". Could also mean Saturday in Polish …': { 1247 so: 0, 1242 1248 }, 'Bitte benutze die englische Abkürzung "<ok>" für "<ko>".': { 1243 so: 0, 1244 son: 0, 1245 sonntag: 0, 1246 montag: 1, 1247 di: 2, 1248 die: 2, 1249 dienstag: 2, 1250 mi: 3, 1251 mit: 3, 1252 mittwoch: 3, 1253 'do': 4, 1254 don: 4, 1255 donnerstag: 4, 1256 fre: 5, 1257 freitag: 5, 1258 sam: 6, 1259 samstag: 6, 1249 son: 0, 1250 sonntag: 0, 1251 sonntags: 0, 1252 montag: 1, 1253 montags: 1, 1254 di: 2, 1255 die: 2, 1256 dienstag: 2, 1257 dienstags: 2, 1258 mi: 3, 1259 mit: 3, 1260 mittwoch: 3, 1261 mittwochs: 3, 1262 'do': 4, 1263 don: 4, 1264 donnerstag: 4, 1265 donnerstags: 4, 1266 fre: 5, 1267 freitag: 5, 1268 freitags: 5, 1269 sam: 6, 1270 samstag: 6, 1271 samstags: 6, 1260 1272 }, 'S\'il vous plaît utiliser l\'abréviation "<ok>" pour "<ko>".': { 1261 1273 dim: 0, … … 1291 1303 zat: 6, 1292 1304 zaterdag: 6, 1293 }, 'Please use the englisch abbreviation "<ok>" for "<ko>".': { // FIXME: Translate to Czech.1305 }, 'Please use the English abbreviation "<ok>" for "<ko>".': { // FIXME: Translate to Czech. 1294 1306 'neděle': 0, 1295 1307 'ne': 0, … … 1305 1317 'pá': 5, 1306 1318 'sobota': 6, 1307 }, 'Please use the englisch abbreviation "<ok>" for "<ko>".': {1319 }, 'Please use the English abbreviation "<ok>" for "<ko>".': { 1308 1320 // Spanish. 1309 1321 'martes': 0, … … 1331 1343 'fredag': 5, 1332 1344 'lördag': 6, 1345 // Polish 1346 'niedziela': 0, 'niedz': 0, 'n': 0, 'ndz': 0, 1347 'poniedziałek': 1, 'poniedzialek': 1, 'pon': 1, 'pn': 1, 1348 'wtorek': 2, 'wt': 2, 1349 'środa': 3, 'sroda': 3, 'śr': 3, 'sr': 3, 1350 'czwartek': 4, 'czw': 4, 'cz': 4, 1351 'piątek': 5, 'piatek': 5, 'pt': 5, 1352 'sobota': 6, 'sob': 6, // 'so': 6 // abbreviation also used in German 1333 1353 }, 1334 1354 }, … … 1569 1589 curr_block_tokens.push([tmp[0].toLowerCase(), 'calcday', value.length ]); 1570 1590 value = value.substr(tmp[0].length); 1571 } else if (tmp = value.match(/^(&|–| [a-zA-ZäÄàÀéÉ]+\b)\.?/i)) {1591 } else if (tmp = value.match(/^(&|–|~|[a-zA-ZäÄàÀéÉ]+\b)\.?/i)) { 1572 1592 // Handle all remaining words with error tolerance 1573 1593 var correct_val = returnCorrectWordOrToken(tmp[1].toLowerCase(), value.length); … … 1740 1760 || matchTokens(tokens, at, 'year', 'event') 1741 1761 || matchTokens(tokens, at, 'event')) { 1742 at = parseMonthdayRange(tokens, at );1762 at = parseMonthdayRange(tokens, at, nblock); 1743 1763 week_stable = false; 1744 1764 } else if (matchTokens(tokens, at, 'year')) { … … 1751 1771 at = parseWeekRange(tokens, at + 1); 1752 1772 week_stable = false; 1773 1774 // if (prettified_group_value[-1] != ' ') 1775 // prettified_group_value = prettified_group_value.substring(0, prettified_group_value.length - 1); 1753 1776 } else if (at != 0 && at != tokens.length - 1 && tokens[at][0] == ':') { 1754 1777 // Ignore colon if they appear somewhere else than as time separator. 1778 // Except the start or end of the value. 1755 1779 // This provides compatibility with the syntax proposed by Netzwolf: 1756 // http://w ww.netzwolf.info/en/cartography/osm/time_domain/specification1780 // http://wiki.openstreetmap.org/wiki/Key:opening_hours:specification 1757 1781 if (!done_with_warnings && matchTokens(tokens, at-1, 'weekday') || matchTokens(tokens, at-1, 'holiday')) 1758 1782 parsing_warnings.push([nblock, at, 'Please don’t use ":" after ' + tokens[at-1][1] + '.']); … … 1763 1787 } else if (matchTokens(tokens, at, 'number', 'timesep') 1764 1788 || matchTokens(tokens, at, 'timevar') 1765 || matchTokens(tokens, at, '(', 'timevar')) { 1789 || matchTokens(tokens, at, '(', 'timevar') 1790 || matchTokens(tokens, at, 'number', '-')) { 1766 1791 at = parseTimeRange(tokens, at, selectors); 1767 1792 … … 1833 1858 1834 1859 if (typeof conf != 'undefined') { 1860 1861 // 'Mo: 12:00-13:00' -> 'Mo 12:00-13:00' 1862 if (used_subparsers['time ranges'] && old_at > 1 && tokens[old_at-1][0] == ':' 1863 && matchTokens(tokens, old_at - 2, 'weekday')) 1864 prettified_group_value = prettified_group_value.substring(0, prettified_group_value.length - 2) + ' '; 1865 1866 // 'week 1, week 3' -> 'week 1,week 3' 1867 if (prettified_group_value.substr(prettified_group_value.length -2, 2) == ', ' 1868 && matchTokens(tokens, old_at, 'week')) 1869 prettified_group_value = prettified_group_value.substring(0, prettified_group_value.length - 1); 1870 1835 1871 prettified_group_value += prettifySelector(tokens, old_at, at, conf, used_subparsers['time ranges']); 1836 1872 } … … 2043 2079 (has_normal_time[1] ? 3 : (has_time_var_calc[1] ? 7 : !has_open_end)) 2044 2080 ); 2081 } else if (matchTokens(tokens, at, 'number', '-', 'number')) { // "Mo 09-18" -> "Mo 09:00-18:00". Please don’t use this 2082 var minutes_from = tokens[at][0] * 60; 2083 var minutes_to = tokens[at+2][0] * 60; 2084 if (!done_with_warnings) 2085 parsing_warnings.push([nblock, at + 2, 2086 'Time range without minutes specified. Not very explicit! Please use this syntax instead e.g. "12:00-14:00".']); 2087 2088 if (minutes_from >= minutes_in_day) 2089 throw formatWarnErrorMessage(nblock, at, 2090 'Time range starts outside of the current day'); 2091 if (minutes_to < minutes_from) 2092 minutes_to += minutes_in_day; 2093 if (minutes_to > minutes_in_day * 2) 2094 throw formatWarnErrorMessage(nblock, at + 2, 2095 'Time spanning more than two midnights not supported'); 2096 2097 if (minutes_to > minutes_in_day) { 2098 selectors.time.push(function(minutes_from, minutes_to) { return function(date) { 2099 var ourminutes = date.getHours() * 60 + date.getMinutes(); 2100 2101 if (ourminutes < minutes_from) 2102 return [false, dateAtDayMinutes(date, minutes_from)]; 2103 else 2104 return [true, dateAtDayMinutes(date, minutes_to)]; 2105 }}(minutes_from, minutes_to)); 2106 2107 selectors.wraptime.push(function(minutes_from, minutes_to) { return function(date) { 2108 var ourminutes = date.getHours() * 60 + date.getMinutes(); 2109 2110 if (ourminutes < minutes_to) 2111 return [true, dateAtDayMinutes(date, minutes_to)]; 2112 else 2113 return [false, undefined]; 2114 }}(minutes_from, minutes_to - minutes_in_day)); 2115 } else { 2116 selectors.time.push(function(minutes_from, minutes_to) { return function(date) { 2117 var ourminutes = date.getHours() * 60 + date.getMinutes(); 2118 2119 if (ourminutes < minutes_from) 2120 return [false, dateAtDayMinutes(date, minutes_from)]; 2121 else if (ourminutes < minutes_to) 2122 return [true, dateAtDayMinutes(date, minutes_to), has_open_end]; 2123 else 2124 return [false, dateAtDayMinutes(date, minutes_from + minutes_in_day)]; 2125 }}(minutes_from, minutes_to)); 2126 } 2127 2128 at += 3; 2045 2129 } else { // additional block 2046 2130 if (matchTokens(tokens, at, '(')) … … 2633 2717 var is_range = true; 2634 2718 var has_period = true; 2635 if ( tokens[at+4][0] == 1 && !done_with_warnings)2719 if (!done_with_warnings && tokens[at+4][0] == 1) 2636 2720 parsing_warnings.push([nblock, at+1+3, 'Please don’t use year ranges with period equals one (see README)']); 2637 2721 } else { … … 2758 2842 if (!matchTokens(tokens, at, ',')) 2759 2843 break; 2844 2845 if (!matchTokens(tokens, at+1, 'number')) { 2846 at++; // we don‘t need the comma in parseGroup 2847 break; 2848 } 2760 2849 } 2761 2850 … … 2889 2978 // Month day range parser (Jan 26-31; Jan 26-Feb 26) 2890 2979 //====================================================================== 2891 function parseMonthdayRange(tokens, at ) {2980 function parseMonthdayRange(tokens, at, nblock) { 2892 2981 for (; at < tokens.length; at++) { 2893 2982 var has_year = [], has_month = [], has_event = [], has_calc = [], has_constrained_weekday = [], has_calc = []; … … 3055 3144 return [true, to_date]; 3056 3145 3057 var period = tokens[at+5][0]; 3146 var period = tokens[at+has_year+5][0]; 3147 if (!done_with_warnings && period == 1) 3148 parsing_warnings.push([nblock, at+has_year+5, 'Please don’t use day ranges with period equals one (see README)']); 3058 3149 var nday = Math.floor((date.getTime() - from_date.getTime()) / msec_in_day); 3059 3150 var in_period = nday % period; … … 3063 3154 else 3064 3155 return [false, new Date(date.getFullYear(), date.getMonth(), date.getDate() + period - in_period)]; 3156 3065 3157 }}(tokens, at, is_range, has_period, has_year[0])); 3066 3158 … … 3275 3367 var start_at = at; 3276 3368 while (at < last_at) { 3277 if (matchTokens(tokens, at, 'weekday')) { 3369 if (matchTokens(tokens, at, 'weekday')) { // FIXME 3278 3370 if (!conf.leave_weekday_sep_one_day_betw 3279 3371 && at - start_at > 1 && (matchTokens(tokens, at-1, ',') || matchTokens(tokens, at-1, '-')) … … 3284 3376 value += weekdays[tokens[at][0]]; 3285 3377 } else if (at - start_at > 0 && used_parseTimeRange > 0 && matchTokens(tokens, at-1, 'timesep') 3286 && matchTokens(tokens, at, 'number')) { 3378 && matchTokens(tokens, at, 'number')) { // '09:0' -> '09:00' 3287 3379 value += (tokens[at][0] < 10 ? '0' : '') + tokens[at][0].toString(); 3288 3380 } else if (used_parseTimeRange > 0 && conf.leading_zero_hour && at != tokens.length 3289 && matchTokens(tokens, at+1, 'timesep')) { 3381 && matchTokens(tokens, at, 'number') 3382 && matchTokens(tokens, at+1, 'timesep')) { // '9:00' -> '19:00' 3290 3383 value += (tokens[at][0] < 10 ? (tokens[at][0] == 0 && conf.one_zero_if_hour_zero ? '' : '0') : '') + tokens[at][0].toString(); 3384 } else if (used_parseTimeRange > 0 && at + 2 < last_at 3385 && matchTokens(tokens, at, 'number') 3386 && matchTokens(tokens, at+1, '-') 3387 && matchTokens(tokens, at+2, 'number')) { // '9-18' -> '09:00-18:00' 3388 value += (tokens[at][0] < 10 ? (tokens[at][0] == 0 && conf.one_zero_if_hour_zero ? '' : '0') : '') + tokens[at][0].toString(); 3389 value += ':00-'; 3390 value += (tokens[at+2][0] < 10 ? '0' : '') + tokens[at+2][0].toString(); 3391 value += ':00'; 3392 at += 3; 3291 3393 } else if (matchTokens(tokens, at, 'comment')) { 3292 3394 value += '"' + tokens[at][0].toString() + '"'; … … 3307 3409 value += months[[tokens[at][0]]]; 3308 3410 if (at + 1 < last_at && matchTokens(tokens, at+1, 'weekday')) 3309 value += ' ';3411 value += ' '; 3310 3412 } else if (at + 2 < last_at 3311 3413 && (matchTokens(tokens, at, '-') || matchTokens(tokens, at, '+')) -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java
r6415 r6420 82 82 83 83 @Test 84 public void testCheckOpeningHourSyntaxTicket9367() throws Exception { 85 final String key = "opening_hours"; 86 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getSeverity(), is(Severity.WARNING)); 87 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getMessage(), is("Mo,Tu 04-17 <--- (Time range without minutes specified. Not very explicit! Please use this syntax instead e.g. \"12:00-14:00\".)")); 88 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getPrettifiedValue(), is("Mo,Tu 04:00-17:00")); 89 } 90 91 @Test 84 92 public void testCheckServiceTimeSyntax1() throws Exception { 85 93 final String key = "service_times";
Note:
See TracChangeset
for help on using the changeset viewer.