isDate function compacted