Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -36,7 +36,7 @@ class _DateTime extends \DateTime
|
||||
if ( !$bypassTimezone AND \IPS\Dispatcher::hasInstance() and \IPS\Member::loggedIn()->timezone )
|
||||
{
|
||||
$validTimezone = TRUE;
|
||||
if( in_array( \IPS\Member::loggedIn()->timezone, \DateTimeZone::listIdentifiers() ) )
|
||||
if( in_array( \IPS\Member::loggedIn()->timezone, static::getTimezoneIdentifiers() ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -65,6 +65,27 @@ class _DateTime extends \DateTime
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached timezone identifiers
|
||||
*/
|
||||
protected static $timeZoneIdentifiers = NULL;
|
||||
|
||||
/**
|
||||
* Get the valid time zone identifiers
|
||||
*
|
||||
* @note Abstracted to implement caching
|
||||
* @return array
|
||||
*/
|
||||
public static function getTimezoneIdentifiers()
|
||||
{
|
||||
if( static::$timeZoneIdentifiers === NULL )
|
||||
{
|
||||
static::$timeZoneIdentifiers = \DateTimeZone::listIdentifiers();
|
||||
}
|
||||
|
||||
return static::$timeZoneIdentifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create New
|
||||
@@ -156,10 +177,11 @@ class _DateTime extends \DateTime
|
||||
* Format the date and time according to the user's locale
|
||||
*
|
||||
* @return string
|
||||
* @note We cast to a string explicitly because in some environments (e.g. Windows) boolean FALSE can be returned from strftime if conversion specifiers are not valid
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->convertString( strftime( '%x ' . static::localeTimeFormat(), $this->getTimestamp() + $this->getTimezone()->getOffset( $this ) ) );
|
||||
return (string) \IPS\Member::loggedIn()->language()->convertString( strftime( '%x ' . static::localeTimeFormat(), $this->getTimestamp() + $this->getTimezone()->getOffset( $this ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,7 +319,7 @@ class _DateTime extends \DateTime
|
||||
public function relative( $format=0, $memberOrLanguage=NULL )
|
||||
{
|
||||
$language = static::determineLanguage( $memberOrLanguage );
|
||||
$now = static::create();
|
||||
$now = static::ts( time() );
|
||||
$difference = $this->diff( $now );
|
||||
$capitalKey = ( $format == static::RELATIVE_FORMAT_LOWER ) ? '' : '_c';
|
||||
|
||||
@@ -306,7 +328,7 @@ class _DateTime extends \DateTime
|
||||
{
|
||||
if( $difference->y )
|
||||
{
|
||||
return $language->addToStack( 'f_years_short', FALSE, array( 'sprintf' => array( $difference->y ) ) );
|
||||
return $language->addToStack( 'f_years_short', FALSE, array( 'pluralize' => array( $difference->y ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -348,7 +370,7 @@ class _DateTime extends \DateTime
|
||||
/* Short format: "1 dy" */
|
||||
if ( $format === static::RELATIVE_FORMAT_SHORT )
|
||||
{
|
||||
return $language->addToStack( 'f_days_short', FALSE, array( 'sprintf' => array( $difference->d ) ) );
|
||||
return $language->addToStack( 'f_days_short', FALSE, array( 'pluralize' => array( $difference->d ) ) );
|
||||
}
|
||||
/* Yesterday: "Yesterday at 23:56" */
|
||||
elseif ( $difference->d == 1 && ( $compare->add( new \DateInterval( 'P1D' ) )->format( 'Y-m-d', $language ) == $now->format( 'Y-m-d', $language ) ) )
|
||||
@@ -367,7 +389,7 @@ class _DateTime extends \DateTime
|
||||
/* Short format: "1 hr" */
|
||||
if ( $format == static::RELATIVE_FORMAT_SHORT )
|
||||
{
|
||||
return $language->addToStack( 'f_hours_short', FALSE, array( 'sprintf' => array( $difference->h ) ) );
|
||||
return $language->addToStack( 'f_hours_short', FALSE, array( 'pluralize' => array( $difference->h ) ) );
|
||||
}
|
||||
/* Long format: "1 hour ago" */
|
||||
else
|
||||
@@ -381,7 +403,7 @@ class _DateTime extends \DateTime
|
||||
/* Short format: "4 min" */
|
||||
if ( $format == static::RELATIVE_FORMAT_SHORT )
|
||||
{
|
||||
return $language->addToStack( 'f_minutes_short', FALSE, array( 'sprintf' => array( $difference->i ) ) );
|
||||
return $language->addToStack( 'f_minutes_short', FALSE, array( 'pluralize' => array( $difference->i ) ) );
|
||||
}
|
||||
/* Short format: "4 minutes ago" */
|
||||
else
|
||||
@@ -394,7 +416,7 @@ class _DateTime extends \DateTime
|
||||
{
|
||||
if ( $format == static::RELATIVE_FORMAT_SHORT )
|
||||
{
|
||||
return $language->addToStack( 'f_minutes_short', FALSE, array( 'sprintf' => array( 1 ) ) );
|
||||
return $language->addToStack( 'f_minutes_short', FALSE, array( 'pluralize' => array( 1 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user