@qso-soft/shared
Version:
Shared library for QSO-soft
11 lines • 634 B
JavaScript
import dayjs from 'dayjs';
export const convertDateStringToISODate = (dateString, splitter = '.', format = 'DD:MM') => {
const [firstPart, secondPart, year] = dateString.split(splitter);
if (firstPart && secondPart && year) {
const isoDate = new Date(Number(year), Number(format === 'DD:MM' ? secondPart : firstPart) - 1, Number(format === 'DD:MM' ? firstPart : secondPart)).toISOString();
return isoDate.substring(0, 10);
}
return '';
};
export const timestampToDayjsDate = (timestamp) => dayjs(typeof timestamp === 'string' ? parseInt(timestamp) : timestamp * 1000);
//# sourceMappingURL=dates.js.map