@omnia/fx-models
Version:
Provide Omnia Fx Models Stuffs.
34 lines (33 loc) • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BirthdayPropertyValue = void 0;
const tslib_1 = require("tslib");
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
const PropertyValue_1 = require("../PropertyValue");
class BirthdayPropertyValue extends PropertyValue_1.PropertyValue {
constructor(birthday, timeZoneId) {
super();
this.timeZoneId = timeZoneId;
if (birthday) {
// Normalise to midnight UTC, stripping any time/timezone offset
const d = dayjs_1.default.utc(birthday);
this.birthday = dayjs_1.default.utc()
.set("year", d.year())
.set("month", d.month())
.set("date", d.date())
.set("hour", 0)
.set("minute", 0)
.set("second", 0)
.set("millisecond", 0)
.toISOString();
}
else {
this.birthday = undefined;
}
this.timeZoneId = "UTC"; // Birthday is always timezone-agnostic
}
isEmpty() {
return !this.birthday;
}
}
exports.BirthdayPropertyValue = BirthdayPropertyValue;