-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace jenssegers/date with Carbon 2.0
- Loading branch information
Luke Towers
committed
Sep 4, 2020
1 parent
93388c8
commit 7c6ef31
Showing
5 changed files
with
74 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,61 @@ | ||
<?php namespace October\Rain\Argon; | ||
|
||
use Jenssegers\Date\Date as DateBase; | ||
use Carbon\Carbon as DateBase; | ||
|
||
/** | ||
* Umbrella class. | ||
*/ | ||
class Argon extends DateBase | ||
{ | ||
/** | ||
* 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