ngx-bootstrap
Version:
Native Angular Bootstrap Components
23 lines • 1.2 kB
JavaScript
var defaultTimeUnit = {
year: 0, month: 0, day: 0, hour: 0, minute: 0, seconds: 0
};
export function createDate(year, month, day, hour, minute, seconds) {
if (month === void 0) { month = 0; }
if (day === void 0) { day = 1; }
if (hour === void 0) { hour = 0; }
if (minute === void 0) { minute = 0; }
if (seconds === void 0) { seconds = 0; }
var _date = new Date();
return new Date(year || _date.getFullYear(), month, day, hour, minute, seconds);
}
export function shiftDate(date, unit) {
var _unit = Object.assign({}, defaultTimeUnit, unit);
return createDate(date.getFullYear() + _unit.year, date.getMonth() + _unit.month, date.getDate() + _unit.day, date.getHours() + _unit.hour, date.getMinutes() + _unit.minute, date.getSeconds() + _unit.seconds);
}
export function setDate(date, unit) {
return createDate(getNum(date.getFullYear(), unit.year), getNum(date.getMonth(), unit.month), getNum(date.getDate(), unit.day), getNum(date.getHours(), unit.hour), getNum(date.getMinutes(), unit.minute), getNum(date.getSeconds(), unit.seconds));
}
function getNum(def, num) {
return typeof num === 'number' ? num : def;
}
//# sourceMappingURL=date-setters.js.map