Bug #44997

JsonView outputs unreliable DateTime representation

Added by Adrian Föder over 8 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
Must have
Assignee:
Category:
MVC
Start date:
2013-01-31
Due date:
% Done:

100%

Estimated time:
PHP Version:
5.3
Has patch:
Yes
Complexity:

Description

Currently, the JsonView just outputs Y-m-d H:i:s as string when it comes to a DateTime object. This is incorrect since it doesn't care about time zones / offsets.

Error case:
  • it's 15:13 GMT, a record is created
  • the record is stored in 14:13 UTC
  • after Hydration, the DateTime object represents 14:13 UTC
  • JsonView's H:i:s makes "14:13" of it
  • (maybe) the string is directly given to JavaScript's new Date() constructor, resulting (due to GMT local time) in 14:13 GMT which is obviously wrong.

Solution: add a timezone offset as in ISO 8601 which is also directly accepted by JavaScript's Date() constructor and probably any other "magical" datetime parser.

#1

Updated by Gerrit Code Review over 8 years ago

  • Status changed from New to Under Review

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/17789

#2

Updated by Gerrit Code Review over 8 years ago

Patch set 1 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/19089

#3

Updated by Adrian Föder over 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF