Skip to content
Browse files

Remove calls to strtotime, in fields and documentation. RE #740

  • Loading branch information...
1 parent 39796ce commit 5c9db57786eb9f3a94cc160b5d1e789bb7f778fd @brendo brendo committed
View
11 symphony/lib/core/class.datetimeobj.php
@@ -118,7 +118,12 @@ public static function setDefaultTimezone($timezone){
* Returns true for valid dates, otherwise false
*/
public static function validate($string) {
- $date = new DateTime(Lang::standardizeDate($string));
+ try {
+ $date = new DateTime(Lang::standardizeDate($string));
+ }
+ catch(Exception $ex) {
+ return false;
+ }
// String is empty or not a valid date
if(empty($string) || $date === false) {
@@ -188,8 +193,8 @@ public static function format($string = 'now', $format = DateTime::ISO8601, $loc
// Attempt to parse the date provided against the Symphony configuration setting
// in an effort to better support multilingual date formats. Should this fail
- // this block will fallback to using `strtotime`, which will parse the date assuming
- // it's in an English format
+ // this block will fallback to just passing the date to DateTime constructor,
+ // which will parse the date assuming it's in an English format
else {
// Standardize date
// Convert date string to English
View
2 symphony/lib/toolkit/class.lang.php
@@ -544,7 +544,7 @@ public static function standardizeDate($string) {
}
// Replace custom date and time separator with space:
- // This is important, otherwise PHP's strtotime() function may break
+ // This is important, otherwise the `DateTime` constructor may break
$separator = Symphony::$Configuration->get('datetime_separator', 'region');
if($separator != ' ') {
$string = str_replace($separator, ' ', $string);
View
4 symphony/lib/toolkit/fields/field.date.php
@@ -397,8 +397,8 @@ public function processRawFieldData($data, &$status, $simulate=false, $entry_id=
if(!is_null($timestamp)) {
return array(
'value' => DateTimeObj::get('c', $timestamp),
- 'local' => strtotime(DateTimeObj::get('c', $timestamp)),
- 'gmt' => strtotime(DateTimeObj::getGMT('c', $timestamp))
+ 'local' => DateTimeObj::get('U', $timestamp),
+ 'gmt' => DateTimeObj::getGMT('U', $timestamp)
);
}

0 comments on commit 5c9db57

Please sign in to comment.
Something went wrong with that request. Please try again.