Version 4.3.6
This commit is contained in:
1 parent
fe1acf984a
commit
1a0c7fd3c2
609 files changed
+14707
-5726
No files matched your search
@@ -95,9 +95,14 @@ class _Date extends \IPS\DateTime
|
||||
public static function getDate( $year=NULL, $month=NULL, $day=NULL, $hour=0, $minute=0, $second=0, $offset=NULL )
|
||||
{
|
||||
/* Get our time zone offset */
|
||||
$timezone = NULL;
|
||||
|
||||
if ( $offset === NULL and \IPS\Member::loggedIn()->timezone )
|
||||
{
|
||||
$offset = \IPS\DateTime::create()->setTimezone( new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) )->getOffset();
|
||||
$timezone = \IPS\DateTime::create();
|
||||
$timezone->setTimezone( new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) );
|
||||
|
||||
$offset = $timezone->getOffset();
|
||||
}
|
||||
|
||||
/* Set appropriate defaults for values not supplied, which is normal */
|
||||
@@ -125,6 +130,14 @@ class _Date extends \IPS\DateTime
|
||||
/* Create the timestamp */
|
||||
$timeStamp = gmmktime( $hour, $minute, $second, $month, $day, $year );
|
||||
|
||||
/* Recalculate offset in case we go over DST boundary */
|
||||
if( $timezone )
|
||||
{
|
||||
$timeZoneCheck = $timezone->setTimestamp( $timeStamp );
|
||||
|
||||
$offset = $timeZoneCheck->getOffset();
|
||||
}
|
||||
|
||||
/* Store the information and return the object */
|
||||
$obj = static::ts( $timeStamp - $offset );
|
||||
$obj->getDateInformation( $timeStamp );
|
||||
@@ -180,7 +193,7 @@ class _Date extends \IPS\DateTime
|
||||
*
|
||||
* @note This is basically a timezone aware wrapper for getdate
|
||||
* @param int $time Timestamp
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
public function getDateInformation( $time )
|
||||
{
|
||||
@@ -197,6 +210,7 @@ class _Date extends \IPS\DateTime
|
||||
'month' => $this->strFormat( '%B' ),
|
||||
0 => $time
|
||||
);
|
||||
return $this->dateInformation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -519,25 +533,18 @@ class _Date extends \IPS\DateTime
|
||||
/**
|
||||
* Return the MySQL-style datetime value
|
||||
*
|
||||
* @param bool $includeTime Whether to include time or not
|
||||
* @param bool $timezoned Whether to adjust for timezone or not. This will usually be FALSE for database purposes, but set to TRUE if you're using this to compare if two dates are on the same day
|
||||
* @param bool $includeTime Whether to include time or not
|
||||
* @return string
|
||||
*/
|
||||
public function mysqlDatetime( $includeTime=TRUE, $timezoned = FALSE )
|
||||
public function mysqlDatetime( $includeTime=TRUE )
|
||||
{
|
||||
$timeStamp = isset( $this->dateInformation[0] ) ? $this->dateInformation[0] : $this->getTimestamp();
|
||||
if ( $timezoned )
|
||||
{
|
||||
$timeStamp += $this->getTimezone()->getOffset( $this );
|
||||
}
|
||||
|
||||
if( $includeTime )
|
||||
{
|
||||
return date( 'Y-m-d H:i:s', $timeStamp );
|
||||
return date( 'Y-m-d H:i:s', isset( $this->dateInformation[0] ) ? $this->dateInformation[0] : $this->getTimestamp() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return date( 'Y-m-d', $timeStamp );
|
||||
return date( 'Y-m-d', isset( $this->dateInformation[0] ) ? $this->dateInformation[0] : $this->getTimestamp() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user