-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee6041e
commit 201a369
Showing
13 changed files
with
75 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace App\Utilities; | ||
|
||
use Carbon\Carbon; | ||
|
||
class Date extends Carbon | ||
{ | ||
/** | ||
* Function to call instead of format. | ||
* | ||
* @var string|callable|null | ||
*/ | ||
protected static $formatFunction = 'translatedFormat'; | ||
|
||
/** | ||
* Function to call instead of createFromFormat. | ||
* | ||
* @var string|callable|null | ||
*/ | ||
protected static $createFromFormatFunction = 'createFromFormatWithCurrentLocale'; | ||
|
||
/** | ||
* Function to call instead of parse. | ||
* | ||
* @var string|callable|null | ||
*/ | ||
protected static $parseFunction = 'parseWithCurrentLocale'; | ||
|
||
public static function parseWithCurrentLocale($time = null, $timezone = null) | ||
{ | ||
if (is_string($time)) { | ||
$time = static::translateTimeString($time, static::getLocale(), 'en'); | ||
} | ||
|
||
return parent::rawParse($time, $timezone); | ||
} | ||
|
||
public static function createFromFormatWithCurrentLocale($format, $time = null, $timezone = null) | ||
{ | ||
if (is_string($time)) { | ||
$time = static::translateTimeString($time, static::getLocale(), 'en'); | ||
} | ||
|
||
return parent::rawCreateFromFormat($format, $time, $timezone); | ||
} | ||
|
||
/** | ||
* Get the language portion of the locale. | ||
* | ||
* @param string $locale | ||
* @return string | ||
*/ | ||
public static function getLanguageFromLocale($locale) | ||
{ | ||
$parts = explode('_', str_replace('-', '_', $locale)); | ||
|
||
return $parts[0]; | ||
} | ||
} |
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
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