1 | <?php |
||
18 | class BnDateTime extends BaseDateTime |
||
19 | { |
||
20 | /** @var DateTime */ |
||
21 | private $_dateTime; |
||
22 | |||
23 | /** @var \DateTime */ |
||
24 | private $_phpDateTime; |
||
25 | |||
26 | protected static $bnMonths = array( |
||
27 | 'F' => array('বৈশাখ','জ্যৈষ্ঠ','আষাঢ়','শ্রাবণ','ভাদ্র','আশ্বিন','কার্তিক','অগ্রহায়ণ','পৌষ','মাঘ','ফাল্গুন','চৈত্র'), |
||
28 | 'M' => array('বৈশাখ','জ্যৈষ্ঠ','আষাঢ়','শ্রাবণ','ভাদ্র','আশ্বিন','কার্তিক','অগ্র','পৌষ','মাঘ','ফাল্গুন','চৈত্র') |
||
29 | ); |
||
30 | |||
31 | protected static $enMonths = array( |
||
32 | 'F' => array('Boishakh','Joishtha','Ashar','Srabon','Bhadra','Ashwin','Kartik','Ogrohayon','Poush','Magh','Falgun','Choitra'), |
||
33 | 'M' => array('Boi','Joi','Ash','Sra','Bha','Ash','Kar','Ogr','Pou','Mag','Fal','Cho') |
||
34 | ); |
||
35 | protected static $daysInMonth = array('', 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30); |
||
36 | protected static $enSuffix = array('th', 'st', 'nd', 'rd'); |
||
37 | |||
38 | protected static $parameterList = array('a', 'A', 'l', 'D'); |
||
39 | |||
40 | private $morning = 6; |
||
41 | |||
42 | public function __construct($time = 'now', \DateTimeZone $timezone = null) |
||
48 | |||
49 | /** |
||
50 | * @param DateTime|\DateTime|BnDateTime|string $time |
||
51 | * |
||
52 | * @return null|BnDateTime |
||
53 | */ |
||
54 | public static function create($time = null) |
||
75 | |||
76 | /** |
||
77 | * @param $time |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | private static function isNullOrBnDateTimeObject($time): bool |
||
85 | |||
86 | public function format($format) |
||
100 | |||
101 | public function enFormat($format) |
||
113 | |||
114 | /** |
||
115 | * @param int $morning |
||
116 | */ |
||
117 | public function setMorning($morning) |
||
121 | |||
122 | public function setDate($year, $month, $day) |
||
134 | |||
135 | /** |
||
136 | * @return DateTime |
||
137 | */ |
||
138 | public function getDateTime() |
||
145 | |||
146 | private function replaceToPlaceHolders($out) { |
||
155 | |||
156 | private function replacePlaceHolders($out) { |
||
164 | |||
165 | /** |
||
166 | * @param $format |
||
167 | * @param $bnDate |
||
168 | * @return string |
||
169 | */ |
||
170 | protected function replaceBnSuffix($format, $bnDate) |
||
174 | |||
175 | protected function replaceDateNumbers($format, $bnDate = array()) |
||
187 | |||
188 | /** |
||
189 | * @return \DateTime |
||
190 | */ |
||
191 | private function getNativeDateTimeObject() |
||
198 | |||
199 | private function getBengaliDateMonthYear() |
||
203 | |||
204 | private function getDayInMonth($month) |
||
212 | |||
213 | protected function getEnSuffix($num) { |
||
223 | |||
224 | /** |
||
225 | * @param $template |
||
226 | * @param $bnDate |
||
227 | * @param $monthArray |
||
228 | * @param $keyTemplate |
||
229 | * @return mixed |
||
230 | */ |
||
231 | protected function replaceMonthString($template, $bnDate, $monthArray, $keyTemplate) |
||
239 | |||
240 | /** |
||
241 | * @param $num |
||
242 | * @return int |
||
243 | */ |
||
244 | protected function getSuffixArrayIndexFromNumber($num) |
||
252 | } |