@nestjs-mod/common
Version:
A collection of utilities for unifying NestJS applications and modules
54 lines • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringToDate = stringToDate;
exports.dateToString = dateToString;
exports.dateToDateString = dateToDateString;
/**
* @deprecated change to @nestjs-mod/misc
*/
function stringToDate(value, addNowTime) {
if (value) {
const now = new Date();
const hour = now.getHours();
const minute = now.getMinutes();
const second = now.getSeconds();
const msecond = now.getMilliseconds();
if (addNowTime) {
return new Date(new Date(+value + hour * 60 * 60 * 100 + minute * 60 * 1000 + second * 1000 + msecond).getTime());
}
else {
return new Date(new Date(value).getTime());
}
}
return null;
}
/**
* @deprecated change to @nestjs-mod/misc
*/
function dateToString(value, defValue, addNowTime) {
const now = new Date();
const hour = now.getHours();
const minute = now.getMinutes();
const second = now.getSeconds();
const msecond = now.getMilliseconds();
if (!value) {
return defValue;
}
if (addNowTime) {
return new Date(+value + hour * 60 * 60 * 100 + minute * 60 * 1000 + second * 1000 + msecond).toISOString();
}
else {
return value.toISOString();
}
}
/**
* @deprecated change to @nestjs-mod/misc
*/
function dateToDateString(value, defValue) {
const d = dateToString(value, defValue);
if (d) {
return d.substring(0, 10);
}
return null;
}
//# sourceMappingURL=date.utils.js.map