Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • DateTime with zone from json datasource to listGrid

    Hello, Isomorphic!

    I got some problems with automatic timezone shift.

    I have RestDataSource with JSON DSDataFormat and some DataSourceDateTimeFields inside.
    When I fetch data from it, I got date as formated string (ex. "yyyy-MM-dd hh:mm Z").

    This datasource is binded to some ListGrid.

    And when date field is displeyed in ListGrid, time is shifted to current client timezone.

    Is it possible to parse DateTime resieved from server with timezone?
    How can I do it?

    Example (client is in GMT+3:00)
    Actual:
    Received datetime in json: "2017-04-19 10:00"
    Displeyed in ListGrid: "2017-04-19 13:00" (is switched to GMT+03:00)

    Expected:
    Received datetime in json: "2017-04-19 10:00 +0300"
    Displeyed in ListGrid: "2017-04-19 10:00" (no switch, cause already in GMT+03:00)

    Hope the problem is clear.
    Thank you!

    PS: I do not want to use DateUtil.setDefaultDisplayTimezone(), cause it is a lots of other ListGrids and DataSources in this project, and they works properly.

  • #2
    In your "Actual" example, the datetime has no timezone, so it is interpreted as UTC/GMT. It is then rendered in the current timezone, correctly.

    If you prefer to deliver dates with a specific timezone offset as with your "expected" example, you can do so, and it will be parsed.

    As far as having the system assume a specific non-UTC timezone when parsing even when no timezone is specified in the date, there's no way to do that, so you would either need to have the data delivered correctly from the server, or add a DataSource.transformResponse() implementation to shift all the date values.

    Comment

    Working...
    X