Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timezone bug when retrieving "time" field?

Tags:

getstream-io

The manual specifies that uniqueness is based on foreign_id and time fields.

I have an activity where a user joins a specific event. The event has its own start date which I want to display in the timelines, therefore I am submitting it as extra data (as well as name and location etc, but I omitted those here to prevent clutter). I submitted the activity with the following activity array to a user feed. Notice I am in Amsterdam, which is (at the moment) in a timezone of GMT+0200:

Array
(
    [actor] => User:3
    [verb] => join
    [object] => Event:2
    [event_start] => 2016-09-26T19:00:00+0200
    [to] => Array
        (
            [0] => notification:2
        )

    [foreign_id] => join:2
    [time] => 2016-09-16T13:29:13+0200
)

When I retrieve that users' user feed, this comes back as:

{  
   "duration":"17ms",
   "next":"",
   "results":[  
      {  
         "actor":"User:3",
         "event_start":"2016-09-26T19:00:00+0200",
         "foreign_id":"join:2",
         "id":"cb0f4a80-7c00-11e6-8080-80010479bedb",
         "object":"Event:2",
         "origin":null,
         "target":null,
         "time":"2016-09-16T11:29:13.000000",
         "to":[  
            "notification:2"
         ],
         "verb":"join"
      }
   ]
}

Notice the difference in the date fields. Both were submitted as ISO8601 fields, but only the event_start field is returned as such. The time field is returned in a different format but without any timezone indicator. It's apparently converted to UTC time but it's lacking the trailing Z that should indicate that. Therefor I cannot reliable use it as a time indicator.

I could work around this by adding another time field to the activity array (which works fine and returns a correct ISO8601 date), but that feels quite redundant.

Is this a bug, am I doing something wrong or should we simply not rely on the time field for an indication of when the activity took place?

like image 360
Anders Avatar asked Sep 16 '16 12:09

Anders


1 Answers

API v1.0 stores the time field in UTC timezone but sadly it does not properly return the trailing Z. This will be fixed in later API versions, but not on this one.

You can safely expect the time field to be always returned as UTC when you query the APIs.

like image 114
Tommaso Barbugli Avatar answered Nov 01 '22 09:11

Tommaso Barbugli