plone / plone.restapi

RESTful API for Plone.
http://plonerestapi.readthedocs.org/
84 stars 75 forks source link

Bug Report: Unexpected "Z" appended to API output #1617

Closed terapyon closed 1 year ago

terapyon commented 1 year ago

I updated plone.restapi version, I found the but for timezone on @history view. My env is JST(UTC+9). I look at this view as 9 hours later.

Description:

Currently, the plone.restapi package outputs datetime values with an appended "Z" at the end, indicating that the datetime is in UTC timezone. However, I think the original data is saved in local timezone as a Unix timestamp in milliseconds.

This behavior can be confusing for users because it is not clear whether the timestamp represents the local time or UTC. Therefore, it may be better to output the datetime value in a format that clearly indicates whether it is in local or UTC timezone.

Steps to Reproduce:

Make a request to the API that returns a datetime value. Inspect the response body. Expected behavior The datetime value should be in a format that clearly indicates whether it is in local or UTC timezone.

Actual behavior:

The datetime value has a "Z" appended at the end, which indicates that it is in UTC timezone. However, the original data is saved in local timezone as a Unix timestamp in milliseconds.

Related PR:

https://github.com/plone/plone.restapi/pull/1531/files

Environment

plone.restapi version: 8.35.2

davisagli commented 1 year ago

Hi @terapyon, I think you are correct that there is a bug here. The timestamp comes from CMFEditions which generates it using time.time(). The code you linked should be converting it to UTC using dt.utcfromtimestamp instead of dt.fromtimestamp.

avoinea commented 1 year ago

@terapyon @davisagli See also: