/
astafievk
/
source_code
Обзор
Документация
Войти
/
astafievk
/
source_code
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Api/node_modules/validator/es/lib/isTime.js
20 строк
619 B
astafievK
source code
21 июн 2024, 21:02
21 июн 2024, 21:02
37a1d03
Код
Авторство
О чём код?
import merge from './util/merge'; var default_time_options = { hourFormat: 'hour24', mode: 'default' }; var formats = { hour24: { "default": /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/, withSeconds: /^([01]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/ }, hour12: { "default": /^(0?[1-9]|1[0-2]):([0-5][0-9]) (A|P)M$/, withSeconds: /^(0?[1-9]|1[0-2]):([0-5][0-9]):([0-5][0-9]) (A|P)M$/ } }; export default function isTime(input, options) { options = merge(options, default_time_options); if (typeof input !== 'string') return false; return formats[options.hourFormat][options.mode].test(input); }