@@ -8,11 +8,11 @@ import PersianCalendarSystem from "../src/calendarSystems/PersianCalendarSystem"
8
8
9
9
describe ( "daysInMonth method with different calendar systems" , ( ) => {
10
10
beforeAll ( ( ) => {
11
+ dayjs . extend ( utc ) ;
12
+ dayjs . extend ( timeZone ) ;
11
13
dayjs . extend ( calendarSystems ) ;
12
14
dayjs . registerCalendarSystem ( "gregory" , new GregoryCalendarSystem ( ) ) ;
13
15
dayjs . registerCalendarSystem ( "persian" , new PersianCalendarSystem ( ) ) ;
14
- dayjs . extend ( utc ) ;
15
- dayjs . extend ( timeZone ) ;
16
16
} ) ;
17
17
18
18
test ( "should return the correct number of days in a month for Gregorian calendar" , ( ) => {
@@ -24,56 +24,51 @@ describe("daysInMonth method with different calendar systems", () => {
24
24
} ) ;
25
25
26
26
test ( "should return the correct number of days in a month for Persian calendar" , ( ) => {
27
- // console.log("TEST_DAYS_IN_MONTH",
28
- // dayjs("2023-03-21").toDate().toLocaleString('en-US', { timeZone: "Europe/Paris" }),
29
- // dayjs("2023-03-21").toCalendarSystem("persian").toDate().toLocaleString('en-US', { timeZone: "Europe/Paris" }),
30
- // dayjs("2023-03-21").tz("Europe/Paris").toCalendarSystem("persian").toDate().toLocaleString('en-US', { timeZone: "Europe/Paris" })
31
- // );
32
- const dateInFarvardin = dayjs ( "2023-03-21" ) . tz ( "Europe/Paris" ) . toCalendarSystem ( "persian" ) ;
27
+ const dateInFarvardin = dayjs ( "2023-03-24" ) . utc ( ) . tz ( "Europe/Paris" ) . toCalendarSystem ( "persian" ) ;
33
28
const daysInFarvardin = dateInFarvardin . daysInMonth ( ) ;
34
29
expect ( daysInFarvardin ) . toBe ( 31 ) ;
35
30
36
- const dateInOrdibehesht = dayjs ( "2023-04-21 " ) . toCalendarSystem ( "persian" ) ;
31
+ const dateInOrdibehesht = dayjs ( "2023-04-25 " ) . toCalendarSystem ( "persian" ) ;
37
32
const daysInOrdibehesht = dateInOrdibehesht . daysInMonth ( ) ;
38
33
expect ( daysInOrdibehesht ) . toBe ( 31 ) ;
39
34
40
- const dateInKhordad = dayjs ( "2023-05-21 " ) . toCalendarSystem ( "persian" ) ;
35
+ const dateInKhordad = dayjs ( "2023-05-30 " ) . toCalendarSystem ( "persian" ) ;
41
36
const daysInKhordad = dateInKhordad . daysInMonth ( ) ;
42
37
expect ( daysInKhordad ) . toBe ( 31 ) ;
43
38
44
- const dateInTir = dayjs ( "2023-06-21 " ) . toCalendarSystem ( "persian" ) ;
39
+ const dateInTir = dayjs ( "2023-06-27 " ) . toCalendarSystem ( "persian" ) ;
45
40
const daysInTir = dateInTir . daysInMonth ( ) ;
46
41
expect ( daysInTir ) . toBe ( 31 ) ;
47
42
48
- const dateInMordad = dayjs ( "2023-07-21 " ) . toCalendarSystem ( "persian" ) ;
43
+ const dateInMordad = dayjs ( "2023-07-23 " ) . toCalendarSystem ( "persian" ) ;
49
44
const daysInMordad = dateInMordad . daysInMonth ( ) ;
50
45
expect ( daysInMordad ) . toBe ( 31 ) ;
51
46
52
- const dateInShahrivar = dayjs ( "2023-08-21 " ) . toCalendarSystem ( "persian" ) ;
47
+ const dateInShahrivar = dayjs ( "2023-08-29 " ) . toCalendarSystem ( "persian" ) ;
53
48
const daysInShahrivar = dateInShahrivar . daysInMonth ( ) ;
54
49
expect ( daysInShahrivar ) . toBe ( 31 ) ;
55
50
56
- const dateInMehr = dayjs ( "2023-09-23 " ) . toCalendarSystem ( "persian" ) ;
51
+ const dateInMehr = dayjs ( "2023-09-26 " ) . toCalendarSystem ( "persian" ) ;
57
52
const daysInMehr = dateInMehr . daysInMonth ( ) ;
58
53
expect ( daysInMehr ) . toBe ( 30 ) ;
59
54
60
- const dateInAban = dayjs ( "2023-10-21 " ) . toCalendarSystem ( "persian" ) ;
55
+ const dateInAban = dayjs ( "2023-10-24 " ) . toCalendarSystem ( "persian" ) ;
61
56
const daysInAban = dateInAban . daysInMonth ( ) ;
62
57
expect ( daysInAban ) . toBe ( 30 ) ;
63
58
64
- const dateInAzar = dayjs ( "2023-11-21 " ) . toCalendarSystem ( "persian" ) ;
59
+ const dateInAzar = dayjs ( "2023-11-28 " ) . toCalendarSystem ( "persian" ) ;
65
60
const daysInAzar = dateInAzar . daysInMonth ( ) ;
66
61
expect ( daysInAzar ) . toBe ( 30 ) ;
67
62
68
- const dateInDey = dayjs ( "2023-12-21 " ) . tz ( "Europe/Paris" ) . toCalendarSystem ( "persian" ) ;
63
+ const dateInDey = dayjs ( "2023-12-28 " ) . tz ( "Europe/Paris" ) . utc ( ) . toCalendarSystem ( "persian" ) ;
69
64
const daysInDey = dateInDey . daysInMonth ( ) ;
70
65
expect ( daysInDey ) . toBe ( 30 ) ;
71
66
72
- const dateInBahman = dayjs ( "2023 -01-21" ) . tz ( "Europe/Paris" ) . toCalendarSystem ( "persian" ) ;
67
+ const dateInBahman = dayjs ( "2024 -01-23" ) . utc ( ) . tz ( "Europe/Paris" ) . toCalendarSystem ( "persian" ) ;
73
68
const daysInBahman = dateInBahman . daysInMonth ( ) ;
74
69
expect ( daysInBahman ) . toBe ( 30 ) ;
75
70
76
- const dateInEsfand = dayjs ( "2024-02-20 " ) . toCalendarSystem ( "persian" ) ;
71
+ const dateInEsfand = dayjs ( "2024-03-15" ) . tz ( "Europe/Paris ") . toCalendarSystem ( "persian" ) ;
77
72
const daysInEsfand = dateInEsfand . daysInMonth ( ) ;
78
73
expect ( daysInEsfand ) . toBe ( 29 ) ; // Esfand in a leap year has 29 days
79
74
} ) ;
0 commit comments