Skip to content

Commit ecd2f7d

Browse files
committed
chore(service/command): Added and useless logs are deleted
1 parent dd891c7 commit ecd2f7d

1 file changed

Lines changed: 1 addition & 38 deletions

File tree

src/service/command/date.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
import { Context } from "grammy";
22
import { SafeExecution } from "../../decorators/SafeExecution";
3-
import { Logger } from "../../config/logger";
4-
const logger = new Logger({
5-
file: "date-command.log",
6-
level: "info",
7-
timestampFormat: "locale",
8-
jsonFormat: true,
9-
});
10-
113
export class DateCommand {
124
@SafeExecution()
135
static async date(ctx: Context) {
14-
logger.info("Date command invoked.", "Date", {
15-
chatId: ctx.chat?.id!,
16-
userId: ctx.from?.id!,
17-
});
186

197
const now = new Date();
208

219
// Format Gregorian Date
2210
const gregorianDate = this.formatGregorianDate(now);
23-
logger.info("Gregorian date formatted.", "Date", { gregorianDate });
24-
2511
// Convert to Persian Date
2612
const persianDate = this.convertToPersianDate(now);
27-
logger.info("Persian date converted.", "Date", { persianDate });
28-
2913
// Reply with both date formats
3014
await ctx.reply(
3115
`Gregorian Date: **${gregorianDate}**\n
@@ -35,8 +19,6 @@ Persian Date: **${persianDate}**`,
3519
}
3620

3721
static formatGregorianDate(date: Date): string {
38-
logger.debug("Formatting Gregorian date.", "Date", { date });
39-
4022
const days = [
4123
"Sunday",
4224
"Monday",
@@ -75,15 +57,11 @@ Persian Date: **${persianDate}**`,
7557
// Gy: Gregorian year
7658
// Gm: Gregorian month (1-12)
7759
// Gd: Gregorian day of the month (1-31)
78-
79-
logger.debug("Converting to Persian date.", "Date", { date });
8060
const persianDate = this.toJalaali(
8161
date.getFullYear(),
8262
date.getMonth() + 1,
8363
date.getDate()
8464
);
85-
logger.debug("Persian date calculated.", "Date", { persianDate });
86-
8765
const persianDays = [
8866
"شنبه",
8967
"یکشنبه",
@@ -108,20 +86,14 @@ Persian Date: **${persianDate}**`,
10886
"بهمن",
10987
"اسفند",
11088
];
111-
112-
const dayName = persianDays[date.getDay()+1];
89+
const dayName = Number(date.getDay() + 1) >= 7?persianDays[date.getDay() - 6] : persianDays[date.getDay()+1];
11390
const hours = date.getHours().toString().padStart(2, "0");
11491
const minutes = date.getMinutes().toString().padStart(2, "0");
11592

11693
return `${dayName} ${persianDate.jd} ${persianMonths[persianDate.jm - 1]} ${ persianDate.jy } ساعت: ${hours}:${minutes}`;
11794
}
11895

11996
static toJalaali(gy: number, gm: number, gd: number) {
120-
logger.debug("Converting Gregorian date to Jalaali.", "Date", {
121-
gy,
122-
gm,
123-
gd,
124-
});
12597

12698
const g_d_m = [
12799
0,
@@ -165,15 +137,6 @@ Persian Date: **${persianDate}**`,
165137

166138
// Day Calculation
167139
const jd = (days < 186) ? (days % 31) : ((days - 186) % 30);
168-
169-
console.log("jm", jm);
170-
console.log("jd", jd);
171-
172-
logger.debug("Jalaali date converted.", "Date", {
173-
jy,
174-
jm,
175-
jd,
176-
});
177140
return { jy, jm, jd };
178141
}
179142
}

0 commit comments

Comments
 (0)