Timezone bug when retrieving “time” field?

怎甘沉沦 提交于 2021-01-27 04:48:49

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/39531436/timezone-bug-when-retrieving-time-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!