From 3411794a081abbbf3533ddb34f44ef6e7ccc2ab3 Mon Sep 17 00:00:00 2001 From: Sipachev Igor Date: Tue, 22 Mar 2022 18:17:29 +0700 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D0=B3=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Generators/PersonalIdGenerator.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/popup/src/classes/Service/Generators/PersonalIdGenerator.ts b/popup/src/classes/Service/Generators/PersonalIdGenerator.ts index 234eb11..9a6208c 100644 --- a/popup/src/classes/Service/Generators/PersonalIdGenerator.ts +++ b/popup/src/classes/Service/Generators/PersonalIdGenerator.ts @@ -8,11 +8,7 @@ export class PersonalIdGenerator { * @param person */ generate (person: Person) { - let fullYear = person.birthday.year - if (!fullYear) { - const e = (new Date()).getFullYear() - fullYear = BigInt(randomGenerator.generate(e - 5, e - 55)) - } + const fullYear = this.grabFullYear(person.birthday.year) const year = this.getYearPart(fullYear) const month = this.getMonthPart(person.birthday.month) const day = this.getDayPart(person.birthday.day) @@ -24,6 +20,14 @@ export class PersonalIdGenerator { return a + year + month + day + o + l2 } + grabFullYear (year: bigint | null): bigint { + if (!year) { + const e = (new Date()).getFullYear() + year = BigInt(randomGenerator.generate(e - 5, e - 55)) + } + return year + } + /** * e.getYearPart = function () { var e = (new Date).getFullYear();