Initial commit
This commit is contained in:
9
test-time.js
Normal file
9
test-time.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function parseTime(tStr) {
|
||||
if (!tStr) return [12, 0]
|
||||
const p = tStr.toString().split(':').map(Number)
|
||||
return [isNaN(p[0]) ? 12 : p[0], isNaN(p[1]) ? 0 : p[1]]
|
||||
}
|
||||
|
||||
console.log(parseTime('00:00:30'));
|
||||
console.log(parseTime('07:23'));
|
||||
console.log(parseTime(''));
|
||||
Reference in New Issue
Block a user