UNPKG

dbmaster-cli

Version:

Tool for converting tables between Fifa Soccer Games

25 lines (24 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Date.prototype.toFifaDate = function () { // tslint:disable-next-line: no-invalid-this return Math.round((this.getTime() - this.getTimezoneOffset() * 60000) / 8.64e7) + 141428; }; Date.prototype.addYear = function (years) { // tslint:disable-next-line: no-invalid-this return new Date(this.setFullYear(this.getFullYear() + years)); }; Date.prototype.normalize = function () { // tslint:disable-next-line: no-invalid-this return new Date(this.getFullYear(), this.getMonth(), this.getDate(), -this.getTimezoneOffset() / 60, 0, 0); }; Date.prototype.age = function age(refDate) { // tslint:disable-next-line: no-parameter-reassignment refDate = refDate ? refDate.normalize() : new Date().normalize(); // tslint:disable-next-line: no-invalid-this const diff = refDate.getTime() - this.getTime(); return Math.abs(new Date(diff).getUTCFullYear() - 1970); }; Date.fromFifaDate = (value) => { return new Date((value - 141428) * 8.64e7); };