This is fine if the server is in UTC. This is because, when you take a timestamp representing a UTC time and use utcfromtimestamp on it, then derive a timestamp back, you are effectively shifting the time based on the local timezone.
So, when we take the datetime object and convert it back to a timestamp using timestamp(), we are essentially getting the timestamp of 7:00 PM UTC. When this timestamp is treated as an MST time, it would correspond to 12:00 PM MST (noon) + 7 hours = 7:00 PM MST, which is 7 hours into the future.
For example:
Time now: 2023-10-04 06:31:27.191104 MST
=====
From time:1696450860
Until Time:1696451160
https://dashboard.signalsciences.net/api/v0/corps/<corp>/sites/<site>/feed/requests?from=1696450860&until=1696451160
400
{"message":"The from and until timestamps cannot be in the future - see https://docs.signalsciences.net/developer/extract-your-data/"}
1696450860 will convert to Wednesday October 04, 2023 20:21:00 (pm)
The fix for this would not bother converting the timestamp we already generated, as we have to convert it into a datetime object again (and in this process currently, making it naieve).
A fix for this would just be to replace replace=0 operation by truncating the timestamp using arithmetic instead. Thus avoiding handling another datetime object.
It makes more sense to just use epoch timestamps (time.time) across the board here.
This should just ideally be refactored to use that instead and not rely on dt at all.
In the sigsci_helper time stamp sanitisation process:
It is being passing a UTC (aware) time already:
This is fine if the server is in UTC. This is because, when you take a timestamp representing a UTC time and use utcfromtimestamp on it, then derive a timestamp back, you are effectively shifting the time based on the local timezone.
So, when we take the datetime object and convert it back to a timestamp using timestamp(), we are essentially getting the timestamp of 7:00 PM UTC. When this timestamp is treated as an MST time, it would correspond to 12:00 PM MST (noon) + 7 hours = 7:00 PM MST, which is 7 hours into the future.
For example:
1696450860 will convert to Wednesday October 04, 2023 20:21:00 (pm)
The fix for this would not bother converting the timestamp we already generated, as we have to convert it into a datetime object again (and in this process currently, making it naieve).
A fix for this would just be to replace
replace=0
operation by truncating the timestamp using arithmetic instead. Thus avoiding handling another datetime object.e.g: