File tree Expand file tree Collapse file tree 1 file changed +5
-18
lines changed
eZ/Publish/Core/FieldType/DateAndTime Expand file tree Collapse file tree 1 file changed +5
-18
lines changed Original file line number Diff line number Diff line change 1010use eZ \Publish \Core \Base \Exceptions \InvalidArgumentValue ;
1111use Exception ;
1212use DateTime ;
13- use DateTimeZone ;
1413
1514/**
1615 * Value for DateAndTime field type.
@@ -51,7 +50,7 @@ public function __construct(DateTime $dateTime = null)
5150 public static function fromString ($ dateString )
5251 {
5352 try {
54- return new static (static :: getDateTime ($ dateString ));
53+ return new static (new DateTime ($ dateString ));
5554 } catch (Exception $ e ) {
5655 throw new InvalidArgumentValue ('$dateString ' , $ dateString , __CLASS__ , $ e );
5756 }
@@ -67,27 +66,15 @@ public static function fromString($dateString)
6766 public static function fromTimestamp ($ timestamp )
6867 {
6968 try {
70- return new static (static ::getDateTime ("@ {$ timestamp }" ));
69+ $ dateTime = new DateTime ();
70+ $ dateTime ->setTimestamp ($ timestamp );
71+
72+ return new static ($ dateTime );
7173 } catch (Exception $ e ) {
7274 throw new InvalidArgumentValue ('$timestamp ' , $ timestamp , __CLASS__ , $ e );
7375 }
7476 }
7577
76- /**
77- * Creates a DateTime object from the string with respecting server timezone.
78- *
79- * @param string $datetime
80- *
81- * @return \DateTime
82- */
83- public static function getDateTime ($ datetime )
84- {
85- $ dt = new DateTime ($ datetime );
86- $ dt ->setTimezone (new DateTimeZone (date_default_timezone_get ()));
87-
88- return $ dt ;
89- }
90-
9178 /**
9279 * @see \eZ\Publish\Core\FieldType\Value
9380 */
You can’t perform that action at this time.
0 commit comments