@@ -26,23 +26,17 @@ class functions extends JDF
2626 /**
2727 * Will Change yyyy-mm-dd hh:ii:ss from gregorian to shmsi(jalali)
2828 * @param $in_datetime
29+ * @param string $delimiter
30+ * @param string $target jalali | gregory
2931 * @return string will return string date and if DateTime was =='0000-00-00 00:00:00' will return '---'
3032 * @todo debug delimiter
3133 */
32- public function convert_dateTime ($ in_datetime , $ delimiter = null )
34+ public function convert_dateTime ($ in_datetime ,$ target = ' jalali ' , $ delimiter = ' - ' )
3335 {
3436 if ($ in_datetime && $ in_datetime != '0000-00-00 00:00:00 ' ) {
35-
36- if ($ delimiter ) {
37- $ datetime = explode ($ delimiter , $ in_datetime );
38-
39-
40- } else {
41- $ datetime = explode (' ' , $ in_datetime );
42-
43- }
44-
45- return self ::jdate ('Y/m/d ' , strtotime ($ datetime [0 ])).' - ' .$ datetime [1 ];
37+ $ dateExplited = explode (' ' , $ in_datetime );
38+ $ out = $ this ->convert_date ($ dateExplited [0 ], $ target ,$ delimiter ).(!empty ($ dateExplited [1 ])?' ' .$ dateExplited [1 ]:'' );
39+ return $ out ;
4640 }
4741
4842 return '--- ' ;
@@ -117,8 +111,9 @@ public function convert_date($in_date, string $target = 'jalali', string $delimi
117111 if ($ in_date == '0000-00-00 ' ) {
118112 return null ;
119113 }
120-
121- return str_replace ('/ ' , $ delimiter , self ::jdate ('Y/m/d ' , strtotime ($ in_date )));
114+ $ converted =self ::jdate ('Y/m/d ' , strtotime ($ in_date ));
115+ $ out = str_replace ('/ ' , $ delimiter ,$ converted );
116+ return $ out ;
122117 }
123118
124119 return null ;
0 commit comments