mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
- Fixed: DbDateValidator returns Unix epoch based date when invalid format is used
This commit is contained in:
parent
b9eefb2ddd
commit
0b4ecd3403
@ -74,7 +74,7 @@ class DateHelper
|
|||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param string $timeValue optional time value
|
* @param string $timeValue optional time value
|
||||||
* @return int timestamp in utc
|
* @return int|false timestamp in utc
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function parseDateTimeToTimestamp($value, $timeValue = null)
|
public static function parseDateTimeToTimestamp($value, $timeValue = null)
|
||||||
|
@ -99,7 +99,7 @@ class DbDateValidator extends DateValidator
|
|||||||
* Parses a date and a time value if timeAttribute is specified.
|
* Parses a date and a time value if timeAttribute is specified.
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return int timestamp in utc
|
* @return int|false timestamp in system timezone
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
protected function parseDateTimeValue($value, $timeValue = null)
|
protected function parseDateTimeValue($value, $timeValue = null)
|
||||||
@ -111,7 +111,7 @@ class DbDateValidator extends DateValidator
|
|||||||
|
|
||||||
$timestamp = $this->parseDateValue($value);
|
$timestamp = $this->parseDateValue($value);
|
||||||
|
|
||||||
if ($this->hasTime() && !empty($timeValue)) {
|
if ($timestamp !== false && $this->hasTime() && !empty($timeValue)) {
|
||||||
$timestamp += $this->parseTimeValue($timeValue);
|
$timestamp += $this->parseTimeValue($timeValue);
|
||||||
$timestamp = $this->fixTimestampTimeZone($timestamp, $this->timeZone);
|
$timestamp = $this->fixTimestampTimeZone($timestamp, $this->timeZone);
|
||||||
}
|
}
|
||||||
@ -155,8 +155,10 @@ class DbDateValidator extends DateValidator
|
|||||||
/**
|
/**
|
||||||
* Parses a date and optionally a time if timeAttribute is specified.
|
* Parses a date and optionally a time if timeAttribute is specified.
|
||||||
*
|
*
|
||||||
|
* Returns false in case the value could not be parsed.
|
||||||
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return int timestamp in utc
|
* @return int|false
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function parseDateTime($value, $timeValue = null)
|
public static function parseDateTime($value, $timeValue = null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user