File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9797 */
9898 'convert_from ' => function ($ date_time ) {
9999
100+ $ config = include 'Gregorian.php ' ;
101+
100102 $ year = $ date_time ->format ('Y ' );
101103
102104 $ month = $ date_time ->format ('m ' );
114116
115117 $ year = $ result [2 ];
116118
119+ if (! $ day || $ config ['leap_year ' ]($ year - 1 ) ) {
120+ $ day ++;
121+ }
122+
117123 $ date_time ->setDate ($ year , $ month , $ day );
118124
119125 return $ date_time ;
177183 *\_________________________________________________________/
178184 */
179185 'days_of_week ' => array (
180-
186+
181187 'al-Aḥad ' ,
182188 'al-Ithnayn ' ,
183189 'ath-Thulatha \'' ,
Original file line number Diff line number Diff line change 161161 $ gregorian_month -= $ value ;
162162 }
163163
164- $ gregorian_day = $ gregorian_month ;
164+ $ gregorian_day = $ gregorian_month ;
165165
166- $ gregorian_month = $ month ;
166+ $ gregorian_month = $ month ;
167167
168- if ( ( ( $ gregorian_year % 4 ) == 0 ) && ( ( ( $ gregorian_year % 100 ) != 0 ) || ( ( $ gregorian_year % 400 ) == 0 ) ) ) {
168+ if ( ( ( $ gregorian_year % 4 ) == 0 ) && ( ( ( $ gregorian_year % 100 ) != 0 ) || ( ( $ gregorian_year % 400 ) == 0 ) ) ) {
169169
170170 if ( $ gregorian_month < 3 || ( $ gregorian_month == 3 && $ gregorian_day < 22 ) ) {
171171
172172 $ gregorian_day ++;
173173
174174 }
175175
176- }
176+ }
177177
178- $ date_time ->setDate ($ gregorian_year , $ gregorian_month , $ gregorian_day );
178+ if (! $ gregorian_day || $ config ['leap_year ' ]($ gregorian_year - 1 ) ) {
179+ $ gregorian_day ++;
180+ }
179181
182+ $ date_time ->setDate ($ gregorian_year , $ gregorian_month , $ gregorian_day );
180183
181- return $ date_time ;
184+ return $ date_time ;
182185
183186 },
184187
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ public function testJalaliToGregorian()
3636
3737 $ this ->assertEquals ('2016-01-25 00:00:00 ' , $ date );
3838
39+ $ date = Datium::create (1396 , 9 , 11 )->from ('jalali ' )->get ();
40+
41+ $ this ->assertEquals ('2017-12-02 00:00:00 ' , $ date );
42+
3943 }
4044
4145 public function testHijriToGregorian ()
@@ -45,6 +49,10 @@ public function testHijriToGregorian()
4549
4650 $ this ->assertEquals ('2016-06-13 00:00:00 ' , $ date );
4751
52+ $ date = Datium::create (1439 , 03 , 12 )->from ('hijri ' )->get ();
53+
54+ $ this ->assertEquals ('2017-12-02 00:00:00 ' , $ date );
55+
4856 }
4957
5058 public function testJalaliToHijri ()
You can’t perform that action at this time.
0 commit comments