class Timestamp { DEFAULT_FORMAT = "Y-m-d H:i:s P"; #date; constructor(init, options = {}) { if (init === 'now') { this.#date = new Date(); } else if (init && init.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}) (.+?)$/)) { let { year, month, day, hour, minute, second, timezone } = init.replace('-',' ').split(); let h = null, m = null; if (timezone.indexOf(':') !== false) { let { h, m } = timezone.split(':'); } else { h = timezone; } this.#date = new Date(year, month, day, hour, minute, second, 0); h = parseInt(h); m = parseInt(m); let t = this.#date.getTime(); let d = ((h * 3600) + (m * 60) * 1000); this.#date.setTime(t -d ); } } get date() { return this.#date; } get time() { return this.format('H:i:s'); } set time(time) { } add(periods) { // return new } sub(periods) { // return new } time(time) { // return new } diff(other) { // return diff } format(format) { // format date } toString() { return this.format(this.DEFAULT_FORMAT); } } function date(when = "now") { return new Timestamp(when); } export { Timestamp, date };