Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Terkin: Timestamps are not accepted #68

Closed
amotl opened this issue Nov 20, 2021 · 2 comments · Fixed by #79
Closed

Compatibility with Terkin: Timestamps are not accepted #68

amotl opened this issue Nov 20, 2021 · 2 comments · Fixed by #79

Comments

@amotl
Copy link
Member

amotl commented Nov 20, 2021

Hi there,

friends of Kotori and Terkin just told us that a timestamp field they added with a patch like hiveeyes/terkin-datalogger#111, would not be accepted by Kotori.

The corresponding slot of the JSON payload looks like:

"timestamp": 1637431069.6585083

With kind regards,
Andreas.

@amotl
Copy link
Member Author

amotl commented Nov 20, 2021

Thoughts

After looking at the code, ac6975f quickly reveals that the routine for parsing the Unix/Epoch time format might only be looking at values of type int.

# Heuristically compute timestamp precision
if isinstance(timestamp, int):
if timestamp >= 1e17 or timestamp <= -1e17:
time_precision = 'n'
elif timestamp >= 1e14 or timestamp <= -1e14:
time_precision = 'u'
elif timestamp >= 1e11 or timestamp <= -1e11:
time_precision = 'ms'

On the other hand, numeric timestamp values seem to be converted to int values beforehand, so everything should be fine.

# Decode timestamp.
chunk['time'] = data[time_field]
if is_number(chunk['time']):
chunk['time'] = int(float(chunk['time']))

We will have to investigate this further on behalf of a software test.

@amotl
Copy link
Member Author

amotl commented Nov 28, 2021

Hi again,

#79 shows that Kotori already accepts fractional epoch timestamps. However, the patch improves this topic a bit more.

With kind regards,
Andreas.

@amotl amotl closed this as completed in #79 Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant