-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change TimeAgo class design pattern, clean codes and remote temporary…
… events class files
- Loading branch information
1 parent
5030dac
commit f2212e3
Showing
21 changed files
with
488 additions
and
718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,28 @@ | ||
<?php | ||
|
||
return array( | ||
return [ | ||
|
||
/************************************************************ | ||
* Default Time Zone | ||
************************************************************ | ||
* | ||
/** | ||
* Define your default time zone | ||
* | ||
*\_________________________________________________________/ | ||
*/ | ||
'timezone' => 'Asia/Tehran', | ||
|
||
/************************************************************ | ||
* Default Language | ||
************************************************************ | ||
* | ||
/** | ||
* Convert algorith to convert Jalali to Gregorian calerndar | ||
* | ||
*\_________________________________________________________/ | ||
*/ | ||
'language' => 'en', | ||
|
||
|
||
|
||
/************************************************************ | ||
* Default calendar | ||
************************************************************ | ||
* | ||
/** | ||
* Convert algorith to convert Jalali to Gregorian calerndar | ||
* | ||
*\_________________________________________________________/ | ||
*/ | ||
'default_calendar' => 'gregorian', | ||
|
||
|
||
'date_interval' => array( 'D', 'M', 'Y', 'HT', 'MT', 'ST' ), | ||
'date_interval' => [ 'D', 'M', 'Y', 'HT', 'MT', 'ST' ], | ||
|
||
|
||
'date_simple' => array( 'day', ' month', ' year', ' hour', ' minute', ' second' ), | ||
'date_simple' => [ 'day', ' month', ' year', ' hour', ' minute', ' second' ], | ||
|
||
); | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* @category Core | ||
* @package OpenCafe\Datium | ||
* @author Mehdi Hosseini <[email protected]> | ||
* @license icense https://opensource.org/licenses/MIT | ||
* @license License https://opensource.org/licenses/MIT | ||
* @link https://github.com/opencafe/datium | ||
* @since Aug 17, 2015 | ||
*/ | ||
|
@@ -20,8 +20,6 @@ | |
use OpenCafe\Tools\Lang; | ||
use OpenCafe\Tools\TimeAgo; | ||
|
||
use OpenCafe\Datium; | ||
|
||
/** | ||
* Main Datium class | ||
* | ||
|
@@ -120,36 +118,36 @@ public function __construct() | |
$this->calendar_type = 'gregorian'; | ||
|
||
switch (Datium::$call_type) { | ||
case 'now': | ||
$this->date_time = new DateTime('now'); | ||
case 'now': | ||
$this->date_time = new DateTime('now'); | ||
|
||
$this->gregorian_DayofWeek = $this->date_time->format('w'); | ||
$this->gregorian_DayofWeek = $this->date_time->format('w'); | ||
|
||
break; | ||
break; | ||
|
||
case 'make': | ||
$this->date_time = new DateTime('now'); | ||
case 'make': | ||
$this->date_time = new DateTime('now'); | ||
|
||
$this->date_time->setDate( | ||
self::$array_date[ 'year' ], | ||
self::$array_date[ 'month' ], | ||
self::$array_date[ 'day' ] | ||
); | ||
$this->date_time->setDate( | ||
self::$array_date[ 'year' ], | ||
self::$array_date[ 'month' ], | ||
self::$array_date[ 'day' ] | ||
); | ||
|
||
$this->date_time->setTime( | ||
self::$array_date[ 'hour' ], | ||
self::$array_date[ 'minute' ], | ||
self::$array_date[ 'second' ] | ||
); | ||
$this->date_time->setTime( | ||
self::$array_date[ 'hour' ], | ||
self::$array_date[ 'minute' ], | ||
self::$array_date[ 'second' ] | ||
); | ||
|
||
$this->gregorian_DayofWeek = $this->date_time->format('w'); | ||
$this->gregorian_DayofWeek = $this->date_time->format('w'); | ||
|
||
break; | ||
break; | ||
|
||
case 'set': | ||
$this->date_time = Datium::$static_date_time; | ||
case 'set': | ||
$this->date_time = Datium::$static_date_time; | ||
|
||
$this->gregorian_DayofWeek = $this->date_time->format('w'); | ||
$this->gregorian_DayofWeek = $this->date_time->format('w'); | ||
} | ||
|
||
$this->convert_calendar = new Convert(); | ||
|
@@ -326,7 +324,21 @@ public function to($calendar) | |
public static function diff($start, $end) | ||
{ | ||
|
||
return date_diff($start, $end); | ||
$difference = date_diff($start, $end); | ||
|
||
$difference->second = $difference->s; | ||
|
||
$difference->minute = $difference->i; | ||
|
||
$difference->hour = $difference->h; | ||
|
||
$difference->day = $difference->d; | ||
|
||
$difference->month = $difference->m; | ||
|
||
$difference->year = $difference->y; | ||
|
||
return $difference; | ||
|
||
} | ||
|
||
|
@@ -348,16 +360,14 @@ public function add($value) | |
|
||
$unit = 'P'; | ||
|
||
if( strpos($this->date_interval_expression, 'T') ) { | ||
|
||
$this->date_interval_expression= str_replace( | ||
'T', | ||
'', | ||
$this->date_interval_expression | ||
); | ||
|
||
$unit = 'PT'; | ||
if (strpos($this->date_interval_expression, 'T')) { | ||
$this->date_interval_expression= str_replace( | ||
'T', | ||
'', | ||
$this->date_interval_expression | ||
); | ||
|
||
$unit = 'PT'; | ||
} | ||
|
||
$this->date_interval_expression = str_replace( | ||
|
@@ -392,16 +402,14 @@ public function sub($value) | |
|
||
$unit = 'P'; | ||
|
||
if( strpos($this->date_interval_expression, 'T') ) { | ||
|
||
$this->date_interval_expression= str_replace( | ||
'T', | ||
'', | ||
$this->date_interval_expression | ||
); | ||
|
||
$unit = 'PT'; | ||
if (strpos($this->date_interval_expression, 'T')) { | ||
$this->date_interval_expression= str_replace( | ||
'T', | ||
'', | ||
$this->date_interval_expression | ||
); | ||
|
||
$unit = 'PT'; | ||
} | ||
|
||
$this->date_interval_expression = str_replace( | ||
|
@@ -442,9 +450,9 @@ public function leap() | |
public function ago() | ||
{ | ||
|
||
$this->ago = new TimeAgo( $this->date_time, $this->language ); | ||
$this->ago = new TimeAgo($this->date_time, $this->language); | ||
|
||
return $this->ago->get(); | ||
return $this->ago; | ||
|
||
} | ||
|
||
|
Oops, something went wrong.