From 7f55c330f1c040832f9463f84f8389ca87e3beb1 Mon Sep 17 00:00:00 2001 From: giuxtaposition Date: Thu, 28 Mar 2024 12:11:58 +0100 Subject: [PATCH] fix: birthdate being wrong format when day is less than 10 --- src/lib/services/fakeDataService.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/services/fakeDataService.ts b/src/lib/services/fakeDataService.ts index 97520d0..d913b2f 100644 --- a/src/lib/services/fakeDataService.ts +++ b/src/lib/services/fakeDataService.ts @@ -63,7 +63,11 @@ class FakeDataService { const year = date.getUTCFullYear(); let month: number | string = date.getUTCMonth() + 1; - const day = date.getUTCDate(); + let day: number | string = date.getUTCDate(); + + if (day < 10) { + day = "0" + day; + } if (month < 10) { month = "0" + month; @@ -85,7 +89,11 @@ class FakeDataService { } public static phone() { - return "3" + faker.string.numeric({ length: 1, exclude: "0" }) + faker.string.numeric({ length: 8 }); + return ( + "3" + + faker.string.numeric({ length: 1, exclude: "0" }) + + faker.string.numeric({ length: 8 }) + ); } public static street() {