Commit 34913bd
committed
feat(service): add date command for Gregorian and Persian date handling
- Introduce `tehranZone` function:
- Adjusts the current date and time to Tehran timezone (UTC+3:30) without considering daylight saving time.
- Add `DateCommand` class:
- Provides functionality to retrieve the current date in both Gregorian and Persian calendars.
- `date` method:
- Returns the formatted Gregorian and Persian dates by combining timezone adjustments and conversion logic.
- Utilizes the `@Catch` decorator to handle potential runtime errors.
- `formatGregorianDate` method:
- Formats a `Date` object into a human-readable string (e.g., "Sunday, January 1, 2024, time: 12:00").
- Includes day names, month names, and padded hours and minutes.
- `convertToPersianDate` method:
- Converts a `Date` object into a Persian calendar format with day names and month names in Farsi.
- Outputs in the format: `<day> <day_of_month> <month_name> <year> ساعت: <hours>:<minutes>`.
- `toJalaali` method:
- Implements a Gregorian-to-Jalaali (Persian calendar) conversion algorithm.
- Calculates Persian year, month, and day based on the input Gregorian date.
- Accounts for leap years and Persian calendar-specific calculations.1 parent 2cb3de7 commit 34913bd
1 file changed
Lines changed: 84 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
0 commit comments