not all numbers are dates
This commit is contained in:
parent
3eb6e3f432
commit
39229c99a3
1 changed files with 11 additions and 1 deletions
|
@ -618,6 +618,16 @@ Ox.URL = function(options) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isDate(str) {
|
||||||
|
var values = /^(-?\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?\.?(\d+)?$/
|
||||||
|
.exec(str);
|
||||||
|
return Boolean(
|
||||||
|
values &&
|
||||||
|
parseInt(values[1]) <= 9999 &&
|
||||||
|
(!values[2] || parseInt(values[2]) <= 12) &&
|
||||||
|
(!values[3] || parseInt(values[3]) <= 31)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function getSpanType(str, types) {
|
function getSpanType(str, types) {
|
||||||
Ox.Log('Core', 'getSpanType', str, types)
|
Ox.Log('Core', 'getSpanType', str, types)
|
||||||
|
@ -633,7 +643,7 @@ Ox.URL = function(options) {
|
||||||
: canBeLocation && length == 4 ? 'location'
|
: canBeLocation && length == 4 ? 'location'
|
||||||
// leaves us with [-]D[.D][,[-]D[.D]]
|
// leaves us with [-]D[.D][,[-]D[.D]]
|
||||||
: canBeDuration ? 'duration'
|
: canBeDuration ? 'duration'
|
||||||
: canBeDate && !/\./.test(str) && !/^\d{7}$/.test(str) && !/^\d{8}$/.test(str) ? 'date'
|
: canBeDate && isDate(str) ? 'date'
|
||||||
: canBeLocation && length == 2 ? 'location'
|
: canBeLocation && length == 2 ? 'location'
|
||||||
: canBeNumber && /^\d+$/.test(str) ? 'number'
|
: canBeNumber && /^\d+$/.test(str) ? 'number'
|
||||||
: canBeString && str.length ? 'string'
|
: canBeString && str.length ? 'string'
|
||||||
|
|
Loading…
Reference in a new issue