Keyword:
${date}= Get Current Date time_zone=UTC result_format=epoch
used in another time zones don't return current UTC timestamp, because in python code time is processed 2 times:
In second step we have utc time, so we don't want convert it from local to utc.
Thanks, need to look this more closely.
You are definitely right, we shouldn't use time.mktime when converting UTC datatime object to epoch seconds, instead we should use calendar.timegm. The problem is that because we use naive datatime objects, we cannot know is the converted dt in UTC or not.
Because the epoch time is same everywhere, regardless timezones or DST, one option would be using datetime.now(), not datetime.utcnow(), if timezone is UTC _and_ result format is epoch.
Proof:
>>> time.mktime(datetime.now().timetuple()) - calendar.timegm(datetime.utcnow().timetuple())
0.0
This ought to be now fixed. The easiest way to avoid this problem is always using local time when getting the current date as epoch time.