28 lines
1.0 KiB
JavaScript
28 lines
1.0 KiB
JavaScript
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
exports.normalizeAccount = normalizeAccount;
|
||
|
|
exports.validateAccount = validateAccount;
|
||
|
|
exports.formatDateForApi = formatDateForApi;
|
||
|
|
exports.parseDateFromApi = parseDateFromApi;
|
||
|
|
function normalizeAccount(account) {
|
||
|
|
return account.replace(/[^0-9]/g, '');
|
||
|
|
}
|
||
|
|
function validateAccount(account) {
|
||
|
|
const normalized = normalizeAccount(account);
|
||
|
|
return /^\d{10,11}$/.test(normalized);
|
||
|
|
}
|
||
|
|
function formatDateForApi(date) {
|
||
|
|
const year = date.getFullYear();
|
||
|
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||
|
|
const day = String(date.getDate()).padStart(2, '0');
|
||
|
|
return `${year}${month}${day}`;
|
||
|
|
}
|
||
|
|
function parseDateFromApi(dateString) {
|
||
|
|
if (!/^\d{8}$/.test(dateString))
|
||
|
|
return null;
|
||
|
|
const year = parseInt(dateString.substring(0, 4), 10);
|
||
|
|
const month = parseInt(dateString.substring(4, 6), 10) - 1;
|
||
|
|
const day = parseInt(dateString.substring(6, 8), 10);
|
||
|
|
return new Date(year, month, day);
|
||
|
|
}
|
||
|
|
//# sourceMappingURL=utils.js.map
|