@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * Get current datetime |
| 185 | 185 | * |
| 186 | 186 | * @since Aug 17 2015 |
| 187 | - * @return object |
|
| 187 | + * @return Datium |
|
| 188 | 188 | */ |
| 189 | 189 | public static function now() |
| 190 | 190 | { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @param integer $minute minute number |
| 206 | 206 | * @param integer $second second number |
| 207 | 207 | * |
| 208 | - * @return object |
|
| 208 | + * @return Datium |
|
| 209 | 209 | */ |
| 210 | 210 | public static function create( |
| 211 | 211 | $year = 2000, |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * @param object $date_start Start of the DateTime |
| 248 | 248 | * @param object $date_end End of the DateTime |
| 249 | 249 | * |
| 250 | - * @return object |
|
| 250 | + * @return Datium |
|
| 251 | 251 | */ |
| 252 | 252 | public static function between($date_start, $date_end) |
| 253 | 253 | { |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @param object $calendar Assigned calendar to when calendar should start. |
| 295 | 295 | * |
| 296 | - * @return object |
|
| 296 | + * @return Datium |
|
| 297 | 297 | */ |
| 298 | 298 | public function to($calendar) |
| 299 | 299 | { |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * |
| 348 | 348 | * @param string $value How much date should be added to current date |
| 349 | 349 | * |
| 350 | - * @return object |
|
| 350 | + * @return Datium |
|
| 351 | 351 | */ |
| 352 | 352 | public function add($value) |
| 353 | 353 | { |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * |
| 390 | 390 | * @param string $value How much date should increase from current date |
| 391 | 391 | * |
| 392 | - * @return obejct |
|
| 392 | + * @return Datium |
|
| 393 | 393 | */ |
| 394 | 394 | public function sub($value) |
| 395 | 395 | { |
@@ -429,9 +429,8 @@ discard block |
||
| 429 | 429 | /** |
| 430 | 430 | * Check if current year is leap or not |
| 431 | 431 | * |
| 432 | - * @param string $type Name of the calendar to caculate leap year |
|
| 433 | 432 | * |
| 434 | - * @return boolean |
|
| 433 | + * @return Leap |
|
| 435 | 434 | */ |
| 436 | 435 | public function leap() |
| 437 | 436 | { |
@@ -445,7 +444,7 @@ discard block |
||
| 445 | 444 | /** |
| 446 | 445 | * Calculate how many time ago datetime happens |
| 447 | 446 | * |
| 448 | - * @return string |
|
| 447 | + * @return TimeAgo |
|
| 449 | 448 | */ |
| 450 | 449 | public function ago() |
| 451 | 450 | { |
@@ -461,7 +460,7 @@ discard block |
||
| 461 | 460 | * |
| 462 | 461 | * @since Aug, 22 2015 |
| 463 | 462 | * |
| 464 | - * @return integer |
|
| 463 | + * @return DayOf |
|
| 465 | 464 | */ |
| 466 | 465 | public function dayOf() |
| 467 | 466 | { |
@@ -494,7 +493,7 @@ discard block |
||
| 494 | 493 | * |
| 495 | 494 | * @since Oct 22, 2015 |
| 496 | 495 | * |
| 497 | - * @return object |
|
| 496 | + * @return DateTime |
|
| 498 | 497 | */ |
| 499 | 498 | public function object() |
| 500 | 499 | { |
@@ -508,7 +507,7 @@ discard block |
||
| 508 | 507 | * |
| 509 | 508 | * @param string $language language short name fa, en, ar ... |
| 510 | 509 | * |
| 511 | - * @return object |
|
| 510 | + * @return Datium |
|
| 512 | 511 | */ |
| 513 | 512 | public function lang($language = 'fa') |
| 514 | 513 | { |
@@ -528,7 +527,7 @@ discard block |
||
| 528 | 527 | /** |
| 529 | 528 | * Return object as timestamp |
| 530 | 529 | * |
| 531 | - * @return timestamp |
|
| 530 | + * @return integer |
|
| 532 | 531 | */ |
| 533 | 532 | public function timestamp() |
| 534 | 533 | { |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | $this->config = include 'Config.php'; |
| 113 | 113 | |
| 114 | - $this->calendar_type = $this->config[ 'default_calendar' ]; |
|
| 114 | + $this->calendar_type = $this->config['default_calendar']; |
|
| 115 | 115 | |
| 116 | - date_default_timezone_set($this->config[ 'timezone' ]); |
|
| 116 | + date_default_timezone_set($this->config['timezone']); |
|
| 117 | 117 | |
| 118 | 118 | $this->calendar_type = 'gregorian'; |
| 119 | 119 | |
@@ -129,15 +129,15 @@ discard block |
||
| 129 | 129 | $this->date_time = new DateTime('now'); |
| 130 | 130 | |
| 131 | 131 | $this->date_time->setDate( |
| 132 | - self::$array_date[ 'year' ], |
|
| 133 | - self::$array_date[ 'month' ], |
|
| 134 | - self::$array_date[ 'day' ] |
|
| 132 | + self::$array_date['year'], |
|
| 133 | + self::$array_date['month'], |
|
| 134 | + self::$array_date['day'] |
|
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | 137 | $this->date_time->setTime( |
| 138 | - self::$array_date[ 'hour' ], |
|
| 139 | - self::$array_date[ 'minute' ], |
|
| 140 | - self::$array_date[ 'second' ] |
|
| 138 | + self::$array_date['hour'], |
|
| 139 | + self::$array_date['minute'], |
|
| 140 | + self::$array_date['second'] |
|
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | 143 | $this->gregorian_DayofWeek = $this->date_time->format('w'); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | public function all() |
| 163 | 163 | { |
| 164 | 164 | |
| 165 | - return ( object ) array( |
|
| 165 | + return (object) array( |
|
| 166 | 166 | |
| 167 | 167 | 'second' => $this->date_time->format('s'), |
| 168 | 168 | |
@@ -353,15 +353,15 @@ discard block |
||
| 353 | 353 | { |
| 354 | 354 | |
| 355 | 355 | $this->date_interval_expression = str_replace( |
| 356 | - $this->config[ 'date_simple' ], |
|
| 357 | - $this->config[ 'date_interval' ], |
|
| 356 | + $this->config['date_simple'], |
|
| 357 | + $this->config['date_interval'], |
|
| 358 | 358 | $value |
| 359 | 359 | ); |
| 360 | 360 | |
| 361 | 361 | $unit = 'P'; |
| 362 | 362 | |
| 363 | 363 | if (strpos($this->date_interval_expression, 'T')) { |
| 364 | - $this->date_interval_expression= str_replace( |
|
| 364 | + $this->date_interval_expression = str_replace( |
|
| 365 | 365 | 'T', |
| 366 | 366 | '', |
| 367 | 367 | $this->date_interval_expression |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | $this->date_interval_expression = str_replace( |
| 374 | 374 | ' ', |
| 375 | 375 | '', |
| 376 | - $unit . $this->date_interval_expression |
|
| 376 | + $unit.$this->date_interval_expression |
|
| 377 | 377 | ); |
| 378 | 378 | |
| 379 | 379 | $this->date_time->add( |
@@ -395,15 +395,15 @@ discard block |
||
| 395 | 395 | { |
| 396 | 396 | |
| 397 | 397 | $this->date_interval_expression = str_replace( |
| 398 | - $this->config[ 'date_simple' ], |
|
| 399 | - $this->config[ 'date_interval' ], |
|
| 398 | + $this->config['date_simple'], |
|
| 399 | + $this->config['date_interval'], |
|
| 400 | 400 | $value |
| 401 | 401 | ); |
| 402 | 402 | |
| 403 | 403 | $unit = 'P'; |
| 404 | 404 | |
| 405 | 405 | if (strpos($this->date_interval_expression, 'T')) { |
| 406 | - $this->date_interval_expression= str_replace( |
|
| 406 | + $this->date_interval_expression = str_replace( |
|
| 407 | 407 | 'T', |
| 408 | 408 | '', |
| 409 | 409 | $this->date_interval_expression |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | $this->date_interval_expression = str_replace( |
| 416 | 416 | ' ', |
| 417 | 417 | '', |
| 418 | - $unit . $this->date_interval_expression |
|
| 418 | + $unit.$this->date_interval_expression |
|
| 419 | 419 | ); |
| 420 | 420 | |
| 421 | 421 | $this->date_time->sub( |
@@ -554,52 +554,52 @@ discard block |
||
| 554 | 554 | // $this->translate_to_file = include( 'Lang/' . $this->language . '/general.php' ); |
| 555 | 555 | |
| 556 | 556 | if (is_null($this->fromConfig)) { |
| 557 | - $this->fromConfig = include 'CalendarSettings/' . |
|
| 558 | - ucfirst($this->translate_from) . '.php'; |
|
| 557 | + $this->fromConfig = include 'CalendarSettings/'. |
|
| 558 | + ucfirst($this->translate_from).'.php'; |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | |
| 562 | 562 | if (is_null($this->toConfig)) { |
| 563 | - $this->toConfig = include 'CalendarSettings/' . |
|
| 564 | - ucfirst($this->translate_to) . '.php'; |
|
| 563 | + $this->toConfig = include 'CalendarSettings/'. |
|
| 564 | + ucfirst($this->translate_to).'.php'; |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | $string_date = $this->date_time->format($format); |
| 568 | 568 | |
| 569 | 569 | if ($this->translate_to != 'gregorian') { |
| 570 | 570 | $string_date = str_replace( |
| 571 | - $this->fromConfig[ 'month' ], |
|
| 572 | - $this->toConfig[ 'month' ], |
|
| 571 | + $this->fromConfig['month'], |
|
| 572 | + $this->toConfig['month'], |
|
| 573 | 573 | $string_date |
| 574 | 574 | ); |
| 575 | 575 | |
| 576 | 576 | $string_date = str_replace( |
| 577 | - $this->fromConfig[ 'days_of_week' ], |
|
| 578 | - $this->toConfig[ 'days_of_week' ][ $this->gregorian_DayofWeek ], |
|
| 577 | + $this->fromConfig['days_of_week'], |
|
| 578 | + $this->toConfig['days_of_week'][$this->gregorian_DayofWeek], |
|
| 579 | 579 | $string_date |
| 580 | 580 | ); |
| 581 | 581 | |
| 582 | 582 | $string_date = str_replace( |
| 583 | - $this->fromConfig[ 'numbers' ], |
|
| 584 | - $this->toConfig[ 'numbers' ], |
|
| 583 | + $this->fromConfig['numbers'], |
|
| 584 | + $this->toConfig['numbers'], |
|
| 585 | 585 | $string_date |
| 586 | 586 | ); |
| 587 | 587 | |
| 588 | 588 | $string_date = str_replace( |
| 589 | - $this->fromConfig[ 'am_time' ], |
|
| 590 | - $this->toConfig[ 'am_time' ], |
|
| 589 | + $this->fromConfig['am_time'], |
|
| 590 | + $this->toConfig['am_time'], |
|
| 591 | 591 | $string_date |
| 592 | 592 | ); |
| 593 | 593 | |
| 594 | 594 | $string_date = str_replace( |
| 595 | - $this->fromConfig[ 'pm_time' ], |
|
| 596 | - $this->toConfig[ 'pm_time' ], |
|
| 595 | + $this->fromConfig['pm_time'], |
|
| 596 | + $this->toConfig['pm_time'], |
|
| 597 | 597 | $string_date |
| 598 | 598 | ); |
| 599 | 599 | |
| 600 | 600 | $string_date = str_replace( |
| 601 | - $this->fromConfig[ 'end_of_days' ], |
|
| 602 | - $this->toConfig[ 'end_of_days' ], |
|
| 601 | + $this->fromConfig['end_of_days'], |
|
| 602 | + $this->toConfig['end_of_days'], |
|
| 603 | 603 | $string_date |
| 604 | 604 | ); |
| 605 | 605 | } |
@@ -63,8 +63,8 @@ |
||
| 63 | 63 | /** |
| 64 | 64 | * Read ago config file |
| 65 | 65 | * |
| 66 | - * @param integer $date date index in ago config file |
|
| 67 | 66 | * @param string $type duration type on ago config file |
| 67 | + * @param integer $value |
|
| 68 | 68 | */ |
| 69 | 69 | public function read( $value, $type ) |
| 70 | 70 | { |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use OpenCafe\Tools\Lang; |
| 6 | 6 | use OpenCafe\Datium; |
| 7 | -use stdClass; |
|
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * Calculate Time ago with current date difference |
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | private $output; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * TimeAgo Class constructure |
|
| 24 | - * |
|
| 25 | - * @param DateTime $time_difference The time to calculate with now |
|
| 26 | - * @param string $lang Language |
|
| 27 | - */ |
|
| 23 | + * TimeAgo Class constructure |
|
| 24 | + * |
|
| 25 | + * @param DateTime $time_difference The time to calculate with now |
|
| 26 | + * @param string $lang Language |
|
| 27 | + */ |
|
| 28 | 28 | public function __construct($time_difference, $lang ) |
| 29 | 29 | { |
| 30 | 30 | |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * Return difference period as an object |
|
| 53 | - * |
|
| 54 | - * @return object |
|
| 55 | - */ |
|
| 52 | + * Return difference period as an object |
|
| 53 | + * |
|
| 54 | + * @return object |
|
| 55 | + */ |
|
| 56 | 56 | public function all() |
| 57 | 57 | { |
| 58 | 58 | |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | - * Read ago config file |
|
| 65 | - * |
|
| 66 | - * @param integer $date date index in ago config file |
|
| 67 | - * @param string $type duration type on ago config file |
|
| 68 | - */ |
|
| 64 | + * Read ago config file |
|
| 65 | + * |
|
| 66 | + * @param integer $date date index in ago config file |
|
| 67 | + * @param string $type duration type on ago config file |
|
| 68 | + */ |
|
| 69 | 69 | public function read( $value, $type ) |
| 70 | 70 | { |
| 71 | 71 | |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * Show priority of duration |
|
| 88 | - * |
|
| 89 | - * @param integer $date date index in ago config file |
|
| 90 | - * @param string $type duration type on ago config file |
|
| 91 | - */ |
|
| 87 | + * Show priority of duration |
|
| 88 | + * |
|
| 89 | + * @param integer $date date index in ago config file |
|
| 90 | + * @param string $type duration type on ago config file |
|
| 91 | + */ |
|
| 92 | 92 | public function priority( $date, $type ) |
| 93 | 93 | { |
| 94 | 94 | |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | - * Return fainal TimeAgo result |
|
| 109 | - * |
|
| 110 | - * @return string |
|
| 111 | - */ |
|
| 108 | + * Return fainal TimeAgo result |
|
| 109 | + * |
|
| 110 | + * @return string |
|
| 111 | + */ |
|
| 112 | 112 | public function get() |
| 113 | 113 | { |
| 114 | 114 | |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | * @param DateTime $time_difference The time to calculate with now |
| 26 | 26 | * @param string $lang Language |
| 27 | 27 | */ |
| 28 | - public function __construct($time_difference, $lang ) |
|
| 28 | + public function __construct($time_difference, $lang) |
|
| 29 | 29 | { |
| 30 | 30 | |
| 31 | 31 | $this->language = $lang; |
| 32 | 32 | |
| 33 | - $now = Datium::now()->object(); |
|
| 33 | + $now = Datium::now()->object(); |
|
| 34 | 34 | |
| 35 | - $this->output = Datium::diff( $now, $time_difference ); |
|
| 35 | + $this->output = Datium::diff($now, $time_difference); |
|
| 36 | 36 | |
| 37 | 37 | $this->year = $this->output->year; |
| 38 | 38 | |
@@ -66,18 +66,18 @@ discard block |
||
| 66 | 66 | * @param integer $date date index in ago config file |
| 67 | 67 | * @param string $type duration type on ago config file |
| 68 | 68 | */ |
| 69 | - public function read( $value, $type ) |
|
| 69 | + public function read($value, $type) |
|
| 70 | 70 | { |
| 71 | 71 | |
| 72 | 72 | $config = include 'config/ago.php'; |
| 73 | 73 | |
| 74 | - if( array_key_exists( $value, $config[ $type ] ) ) { |
|
| 74 | + if (array_key_exists($value, $config[$type])) { |
|
| 75 | 75 | |
| 76 | - return Lang::get( $this->language, $config[ $type ][ $value ] ); |
|
| 76 | + return Lang::get($this->language, $config[$type][$value]); |
|
| 77 | 77 | |
| 78 | 78 | } else { |
| 79 | 79 | |
| 80 | - return $value . " " . Lang::get( $this->language, $config[ $type ][ '*' ] ); |
|
| 80 | + return $value." ".Lang::get($this->language, $config[$type]['*']); |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | * @param integer $date date index in ago config file |
| 90 | 90 | * @param string $type duration type on ago config file |
| 91 | 91 | */ |
| 92 | - public function priority( $date, $type ) |
|
| 92 | + public function priority($date, $type) |
|
| 93 | 93 | { |
| 94 | 94 | |
| 95 | - if( $date != 0 ) { |
|
| 95 | + if ($date != 0) { |
|
| 96 | 96 | |
| 97 | - return $this->read( $date, $type ); |
|
| 97 | + return $this->read($date, $type); |
|
| 98 | 98 | |
| 99 | 99 | } else { |
| 100 | 100 | |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | 'second' => $this->second |
| 122 | 122 | ]; |
| 123 | 123 | |
| 124 | - foreach( $duration as $index => $value ) { |
|
| 124 | + foreach ($duration as $index => $value) { |
|
| 125 | 125 | |
| 126 | - if( $this->priority( $value, $index ) != false ) { |
|
| 126 | + if ($this->priority($value, $index) != false) { |
|
| 127 | 127 | |
| 128 | - return $this->priority( $value, $index ); |
|
| 128 | + return $this->priority($value, $index); |
|
| 129 | 129 | |
| 130 | 130 | } |
| 131 | 131 | |
@@ -20,9 +20,9 @@ |
||
| 20 | 20 | 'default_calendar' => 'gregorian', |
| 21 | 21 | |
| 22 | 22 | |
| 23 | - 'date_interval' => [ 'D', 'M', 'Y', 'HT', 'MT', 'ST' ], |
|
| 23 | + 'date_interval' => ['D', 'M', 'Y', 'HT', 'MT', 'ST'], |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - 'date_simple' => [ 'day', ' month', ' year', ' hour', ' minute', ' second' ], |
|
| 26 | + 'date_simple' => ['day', ' month', ' year', ' hour', ' minute', ' second'], |
|
| 27 | 27 | |
| 28 | 28 | ]; |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * Fetch translated expression to langTable attribute |
| 51 | 51 | */ |
| 52 | - self::$langTable = include 'lang/' . $language . '/general.php'; |
|
| 52 | + self::$langTable = include 'lang/'.$language.'/general.php'; |
|
| 53 | 53 | |
| 54 | 54 | foreach (self::$langTable as $key => $translate) { |
| 55 | - if (isset(self::$config[ $key ])) { |
|
| 56 | - if (self::$config[ $key ]) { |
|
| 57 | - self::$config[ $key ] = $translate; |
|
| 55 | + if (isset(self::$config[$key])) { |
|
| 56 | + if (self::$config[$key]) { |
|
| 57 | + self::$config[$key] = $translate; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public static function get($lang, $value) |
| 72 | 72 | { |
| 73 | 73 | |
| 74 | - $file = include('lang/' . $lang . '/general.php'); |
|
| 74 | + $file = include('lang/'.$lang.'/general.php'); |
|
| 75 | 75 | |
| 76 | 76 | return $file[$value]; |
| 77 | 77 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use OpenCafe\Datium as Datium; |
| 4 | 4 | use OpenCafe\Tools\Leap as Leap; |
| 5 | 5 | |
| 6 | -return array ( |
|
| 6 | +return array( |
|
| 7 | 7 | |
| 8 | 8 | 'timezone' => 'Asia/Tehran', |
| 9 | 9 | |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | 'events' => array(), |
| 13 | 13 | |
| 14 | - 'numbers' => array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'), |
|
| 14 | + 'numbers' => array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'), |
|
| 15 | 15 | |
| 16 | 16 | 'am_time' => 'AM', |
| 17 | 17 | |
| 18 | 18 | 'pm_time' => 'PM', |
| 19 | 19 | |
| 20 | - 'end_of_days' => array( 'th', 'st', 'nd', 'rd' ), |
|
| 20 | + 'end_of_days' => array('th', 'st', 'nd', 'rd'), |
|
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | *\_________________________________________________________/ |
| 31 | 31 | */ |
| 32 | - 'convert_to' => function ($date_time) { |
|
| 32 | + 'convert_to' => function($date_time) { |
|
| 33 | 33 | |
| 34 | 34 | $config = include 'Gregorian.php'; |
| 35 | 35 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $temp_day = 0; |
| 43 | 43 | |
| 44 | 44 | for ($i = 1; $i < $month; $i++) { |
| 45 | - $temp_day += $config[ 'month_days_number' ][ $i ]; |
|
| 45 | + $temp_day += $config['month_days_number'][$i]; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $temp_day += $day; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if ($temp_day <= 79) { |
| 57 | - if (( $year - 1 ) % 4 == 0) { |
|
| 57 | + if (($year - 1) % 4 == 0) { |
|
| 58 | 58 | $temp_day = $temp_day + 11; |
| 59 | 59 | } else { |
| 60 | 60 | $temp_day = $temp_day + 10; |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | $year = $year - 622; |
| 64 | 64 | |
| 65 | 65 | if ($temp_day % 30 == 0) { |
| 66 | - $month = ( $temp_day / 30 ) + 9; |
|
| 66 | + $month = ($temp_day / 30) + 9; |
|
| 67 | 67 | |
| 68 | 68 | $day = 30; |
| 69 | 69 | } else { |
| 70 | - $month = ( $temp_day / 30 ) + 10; |
|
| 70 | + $month = ($temp_day / 30) + 10; |
|
| 71 | 71 | |
| 72 | 72 | $day = $temp_day % 30; |
| 73 | 73 | } |
@@ -78,23 +78,23 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | if ($temp_day <= 186) { |
| 80 | 80 | if ($temp_day % 31 == 0) { |
| 81 | - $month = ( $temp_day / 31 ); |
|
| 81 | + $month = ($temp_day / 31); |
|
| 82 | 82 | |
| 83 | 83 | $day = 31; |
| 84 | 84 | } else { |
| 85 | - $month = ( $temp_day / 31 ) + 1; |
|
| 85 | + $month = ($temp_day / 31) + 1; |
|
| 86 | 86 | |
| 87 | - $day = ( $temp_day % 31 ); |
|
| 87 | + $day = ($temp_day % 31); |
|
| 88 | 88 | } |
| 89 | 89 | } else { |
| 90 | 90 | $temp_day = $temp_day - 186; |
| 91 | 91 | |
| 92 | 92 | if ($temp_day % 30 == 0) { |
| 93 | - $month = ( $temp_day / 30 ) + 6; |
|
| 93 | + $month = ($temp_day / 30) + 6; |
|
| 94 | 94 | |
| 95 | 95 | $day = 30; |
| 96 | 96 | } else { |
| 97 | - $month = ( $temp_day / 30 ) + 7; |
|
| 97 | + $month = ($temp_day / 30) + 7; |
|
| 98 | 98 | |
| 99 | 99 | $day = $temp_day % 30; |
| 100 | 100 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | *\_________________________________________________________/ |
| 117 | 117 | */ |
| 118 | - 'convert_from' => function ($date_time) { |
|
| 118 | + 'convert_from' => function($date_time) { |
|
| 119 | 119 | |
| 120 | 120 | $config = include 'Jalali.php'; |
| 121 | 121 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $days_of_year = 0; |
| 129 | 129 | |
| 130 | - foreach ($config[ 'month_days_number' ] as $mon => $value) { |
|
| 130 | + foreach ($config['month_days_number'] as $mon => $value) { |
|
| 131 | 131 | if ($month > $mon) { |
| 132 | 132 | $days_of_year += $value; |
| 133 | 133 | } |
@@ -135,25 +135,25 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $days_of_year += $day; |
| 137 | 137 | |
| 138 | - $days_of_leap_years = intval(( ( $year - 1 ) / 4 )); |
|
| 138 | + $days_of_leap_years = intval((($year - 1) / 4)); |
|
| 139 | 139 | |
| 140 | - $days_of_shamsi_years = ( ( ( $year - 1 ) * 365 ) + $days_of_year + $days_of_leap_years ); |
|
| 140 | + $days_of_shamsi_years = ((($year - 1) * 365) + $days_of_year + $days_of_leap_years); |
|
| 141 | 141 | |
| 142 | 142 | $days_of_gregorain_years = $days_of_shamsi_years + 226899; |
| 143 | 143 | |
| 144 | 144 | if ($month < 10) { |
| 145 | - $days_of_gregorain_years = $days_of_gregorain_years - intval(( ( $year + 621 ) / 4 )); |
|
| 146 | - } elseif (( ( 10 == $month ) && ( $day > 10 ) ) || ( $month > 10 )) { |
|
| 147 | - $days_of_gregorain_years = $days_of_gregorain_years - intval(( ( $year + 622 ) / 4 )); |
|
| 145 | + $days_of_gregorain_years = $days_of_gregorain_years - intval((($year + 621) / 4)); |
|
| 146 | + } elseif (((10 == $month) && ($day > 10)) || ($month > 10)) { |
|
| 147 | + $days_of_gregorain_years = $days_of_gregorain_years - intval((($year + 622) / 4)); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $gregorian_month = ( $days_of_gregorain_years % 365 ); |
|
| 150 | + $gregorian_month = ($days_of_gregorain_years % 365); |
|
| 151 | 151 | |
| 152 | 152 | $gregorian_year = intval($days_of_gregorain_years / 365) + 1; |
| 153 | 153 | |
| 154 | 154 | $config = include 'Gregorian.php'; |
| 155 | 155 | |
| 156 | - foreach ($config[ 'month_days_number' ] as $month => $value) { |
|
| 156 | + foreach ($config['month_days_number'] as $month => $value) { |
|
| 157 | 157 | if ($gregorian_month < $value) { |
| 158 | 158 | break; |
| 159 | 159 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | *\_________________________________________________________/ |
| 192 | 192 | */ |
| 193 | - 'month' => array ( |
|
| 193 | + 'month' => array( |
|
| 194 | 194 | |
| 195 | 195 | 'Farvardin', |
| 196 | 196 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | |
| 231 | 231 | |
| 232 | - 'days_of_week' => array ( |
|
| 232 | + 'days_of_week' => array( |
|
| 233 | 233 | |
| 234 | 234 | 'Yekshanbe', |
| 235 | 235 | 'Doshanbe', |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | 'start_day_of_week' => 'Shanbe', |
| 245 | 245 | |
| 246 | - 'month_days_number' => array( 1 => 31, |
|
| 246 | + 'month_days_number' => array(1 => 31, |
|
| 247 | 247 | 2 => 31, |
| 248 | 248 | 3 => 31, |
| 249 | 249 | 4 => 31, |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | 9 => 30, |
| 255 | 255 | 10 => 30, |
| 256 | 256 | 11 => 30, |
| 257 | - 12 => 29 ), |
|
| 257 | + 12 => 29), |
|
| 258 | 258 | |
| 259 | 259 | /************************************************************ |
| 260 | 260 | * Day of year |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | *\_________________________________________________________/ |
| 266 | 266 | */ |
| 267 | - 'day_of_year' => function ($date_time) { |
|
| 267 | + 'day_of_year' => function($date_time) { |
|
| 268 | 268 | |
| 269 | 269 | $result = null; |
| 270 | 270 | |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | $day = $date_time->format('d'); |
| 276 | 276 | |
| 277 | - foreach ($config[ 'month_days_number' ] as $_month => $value) { |
|
| 277 | + foreach ($config['month_days_number'] as $_month => $value) { |
|
| 278 | 278 | if ($_month < $month) { |
| 279 | 279 | $result += $value; |
| 280 | 280 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * example : Yekshanbe = result is 2 |
| 295 | 295 | *\_________________________________________________________/ |
| 296 | 296 | */ |
| 297 | - 'day_of_week' => function ($date_time) { |
|
| 297 | + 'day_of_week' => function($date_time) { |
|
| 298 | 298 | |
| 299 | 299 | $days = array( |
| 300 | 300 | 1 => 'Shanbe', |
@@ -312,8 +312,8 @@ discard block |
||
| 312 | 312 | $day = $date_time->format('l'); |
| 313 | 313 | |
| 314 | 314 | $day = str_replace( |
| 315 | - $configGregorian[ 'days_of_week' ], |
|
| 316 | - $configShamsi[ 'days_of_week' ], |
|
| 315 | + $configGregorian['days_of_week'], |
|
| 316 | + $configShamsi['days_of_week'], |
|
| 317 | 317 | $day |
| 318 | 318 | ); |
| 319 | 319 | |
@@ -333,26 +333,26 @@ discard block |
||
| 333 | 333 | * |
| 334 | 334 | *\_________________________________________________________/ |
| 335 | 335 | */ |
| 336 | - 'leap_year' => function ($year) { |
|
| 336 | + 'leap_year' => function($year) { |
|
| 337 | 337 | |
| 338 | 338 | $a = 0.025; |
| 339 | 339 | |
| 340 | 340 | $b = 266; |
| 341 | 341 | |
| 342 | 342 | if ($year > 0) { |
| 343 | - $leapDays0 = (($year + 38) % 2820)*0.24219 + $a; |
|
| 343 | + $leapDays0 = (($year + 38) % 2820) * 0.24219 + $a; |
|
| 344 | 344 | // 0.24219 ~ extra days of one year |
| 345 | - $leapDays1 = (($year + 39) % 2820)*0.24219 + $a; |
|
| 345 | + $leapDays1 = (($year + 39) % 2820) * 0.24219 + $a; |
|
| 346 | 346 | // 38 days is the difference of epoch to 2820-year cycle |
| 347 | 347 | } elseif ($year < 0) { |
| 348 | - $leapDays0 = (($year + 39) % 2820)*0.24219 + $a; |
|
| 349 | - $leapDays1 = (($year + 40) % 2820)*0.24219 + $a; |
|
| 348 | + $leapDays0 = (($year + 39) % 2820) * 0.24219 + $a; |
|
| 349 | + $leapDays1 = (($year + 40) % 2820) * 0.24219 + $a; |
|
| 350 | 350 | } else { |
| 351 | 351 | return false; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $frac0 = intval(($leapDays0 - intval($leapDays0))*1000); |
|
| 355 | - $frac1 = intval(($leapDays1 - intval($leapDays1))*1000); |
|
| 354 | + $frac0 = intval(($leapDays0 - intval($leapDays0)) * 1000); |
|
| 355 | + $frac1 = intval(($leapDays1 - intval($leapDays1)) * 1000); |
|
| 356 | 356 | |
| 357 | 357 | if ($frac0 <= $b && $frac1 > $b) { |
| 358 | 358 | return true; |
@@ -370,6 +370,6 @@ discard block |
||
| 370 | 370 | * |
| 371 | 371 | *\_________________________________________________________/ |
| 372 | 372 | */ |
| 373 | - 'weekend' => array( 'friday' ) |
|
| 373 | + 'weekend' => array('friday') |
|
| 374 | 374 | |
| 375 | 375 | ); |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use OpenCafe\Datium as Datium; |
| 4 | 4 | use OpenCafe\Tools\Leap as Leap; |
| 5 | 5 | |
| 6 | -return array ( |
|
| 6 | +return array( |
|
| 7 | 7 | |
| 8 | 8 | /************************************************************ |
| 9 | 9 | * Convert to |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | *\_________________________________________________________/ |
| 15 | 15 | */ |
| 16 | - 'convert_to' => function ($date_time) { |
|
| 16 | + 'convert_to' => function($date_time) { |
|
| 17 | 17 | |
| 18 | 18 | $config = include 'Jalali.php'; |
| 19 | 19 | |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $day = $date_time->format('d'); |
| 27 | 27 | |
| 28 | - $temp_day = 0 ; |
|
| 28 | + $temp_day = 0; |
|
| 29 | 29 | |
| 30 | 30 | for ($i = 1; $i < $month; $i++) { |
| 31 | - $temp_day += $config[ 'month_days_number' ][ $i ]; |
|
| 31 | + $temp_day += $config['month_days_number'][$i]; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $temp_day += $day; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $temp_day++; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $_year = ( ( ( ( ( $year - 1 ) * 365.2422 ) + $temp_day ) - 119) / 354.3670 ) + 1; |
|
| 42 | + $_year = ((((($year - 1) * 365.2422) + $temp_day) - 119) / 354.3670) + 1; |
|
| 43 | 43 | |
| 44 | 44 | $_year = explode('.', $_year); |
| 45 | 45 | |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $var_temp .= '1'; |
| 57 | 57 | |
| 58 | - $_month = $_month * $var_temp ; |
|
| 58 | + $_month = $_month * $var_temp; |
|
| 59 | 59 | |
| 60 | - $_month = ( $_month * 12 ) + 1; |
|
| 60 | + $_month = ($_month * 12) + 1; |
|
| 61 | 61 | |
| 62 | 62 | $_month = explode('.', $_month); |
| 63 | 63 | |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | $var_temp = '0.0'; |
| 69 | 69 | |
| 70 | 70 | for ($i = strlen($_day); $i > 2; $i--) { |
| 71 | - $var_temp .= '0' ; |
|
| 71 | + $var_temp .= '0'; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $var_temp .= '1'; |
| 75 | 75 | |
| 76 | 76 | $_day = $_day * $var_temp; |
| 77 | 77 | |
| 78 | - $_day = ( $_day * 29.530 ); |
|
| 78 | + $_day = ($_day * 29.530); |
|
| 79 | 79 | |
| 80 | 80 | $_day = explode('.', $_day); |
| 81 | 81 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | *\_________________________________________________________/ |
| 97 | 97 | */ |
| 98 | - 'convert_from' => function ($date_time) { |
|
| 98 | + 'convert_from' => function($date_time) { |
|
| 99 | 99 | |
| 100 | 100 | $config = include 'Hijri.php'; |
| 101 | 101 | |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $day = $date_time->format('d'); |
| 107 | 107 | |
| 108 | - $jd = (int)((11 * $year + 3) / 30) + 354 * $year + |
|
| 109 | - 30 * $month -(int)(($month - 1) / 2) + $day + 1948440 - 385; |
|
| 108 | + $jd = (int) ((11 * $year + 3) / 30) + 354 * $year + |
|
| 109 | + 30 * $month - (int) (($month - 1) / 2) + $day + 1948440 - 385; |
|
| 110 | 110 | |
| 111 | 111 | $result = explode('/', jdtogregorian($jd)); |
| 112 | 112 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | *\_________________________________________________________/ |
| 143 | 143 | */ |
| 144 | - 'month' => array ( |
|
| 144 | + 'month' => array( |
|
| 145 | 145 | |
| 146 | 146 | 'Muharram', |
| 147 | 147 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | *\_________________________________________________________/ |
| 180 | 180 | */ |
| 181 | - 'days_of_week' => array ( |
|
| 181 | + 'days_of_week' => array( |
|
| 182 | 182 | 'al-Aḥad', |
| 183 | 183 | 'al-Ithnayn', |
| 184 | 184 | 'ath-Thulatha\'', |
@@ -189,18 +189,18 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | ), |
| 191 | 191 | |
| 192 | - 'numbers' => array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'), |
|
| 192 | + 'numbers' => array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'), |
|
| 193 | 193 | |
| 194 | 194 | 'am_time' => 'AM', |
| 195 | 195 | |
| 196 | 196 | 'pm_time' => 'PM', |
| 197 | 197 | |
| 198 | - 'end_of_days' => array( 'th', 'st', 'nd', 'rd' ), |
|
| 198 | + 'end_of_days' => array('th', 'st', 'nd', 'rd'), |
|
| 199 | 199 | |
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | |
| 203 | - 'month_days_number' => array( 1 => 30, |
|
| 203 | + 'month_days_number' => array(1 => 30, |
|
| 204 | 204 | 2 => 29, |
| 205 | 205 | 3 => 30, |
| 206 | 206 | 4 => 30, |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | 9 => 30, |
| 212 | 212 | 10 => 29, |
| 213 | 213 | 11 => 30, |
| 214 | - 12 => 30 ), |
|
| 214 | + 12 => 30), |
|
| 215 | 215 | /************************************************************ |
| 216 | 216 | * Day of year |
| 217 | 217 | ************************************************************ |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | *\_________________________________________________________/ |
| 222 | 222 | */ |
| 223 | - 'day_of_year' => function ($date_time) { |
|
| 223 | + 'day_of_year' => function($date_time) { |
|
| 224 | 224 | |
| 225 | 225 | $result = null; |
| 226 | 226 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * example : al-Aḥad = result is 1 |
| 251 | 251 | *\_________________________________________________________/ |
| 252 | 252 | */ |
| 253 | - 'day_of_week' => function ($date_time) { |
|
| 253 | + 'day_of_week' => function($date_time) { |
|
| 254 | 254 | |
| 255 | 255 | $configGhamari = include 'Hijri.php'; |
| 256 | 256 | |
@@ -276,20 +276,20 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | *\_________________________________________________________/ |
| 278 | 278 | */ |
| 279 | - 'leap_year' => function ($year) { |
|
| 279 | + 'leap_year' => function($year) { |
|
| 280 | 280 | $result = $this->year % 30; |
| 281 | 281 | |
| 282 | - if (( 2 == $result ) |
|
| 283 | - || ( 5 == $result ) |
|
| 284 | - || ( 7 == $result ) |
|
| 285 | - || ( 10 == $result ) |
|
| 286 | - || ( 13 == $result ) |
|
| 287 | - || ( 16 == $result ) |
|
| 288 | - || ( 18 == $result ) |
|
| 289 | - || ( 21 == $result ) |
|
| 290 | - || ( 24 == $year ) |
|
| 291 | - || ( 26 == $result ) |
|
| 292 | - || ( 29 == $result ) |
|
| 282 | + if ((2 == $result) |
|
| 283 | + || (5 == $result) |
|
| 284 | + || (7 == $result) |
|
| 285 | + || (10 == $result) |
|
| 286 | + || (13 == $result) |
|
| 287 | + || (16 == $result) |
|
| 288 | + || (18 == $result) |
|
| 289 | + || (21 == $result) |
|
| 290 | + || (24 == $year) |
|
| 291 | + || (26 == $result) |
|
| 292 | + || (29 == $result) |
|
| 293 | 293 | ) { |
| 294 | 294 | return $result; |
| 295 | 295 | } |
@@ -303,6 +303,6 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | *\_________________________________________________________/ |
| 305 | 305 | */ |
| 306 | - 'weekend' => array( 'friday', 'saturday' ), |
|
| 306 | + 'weekend' => array('friday', 'saturday'), |
|
| 307 | 307 | |
| 308 | 308 | ); |