I want to calcualte the total seconds between two arbitrary timestamps.
I have the following:
import datetime
import dateparser
now = datetime.datetime.now(datetime.timezone.utc);
now_bst = dateparser.parse("26April 11:55 am BST");
before = dateparser.parse("25 April 11pm BST");
now.timestamp() - before.timestamp(); # prints 82510.36681008339
now_bst.timestamp() - before.timestamp() #prints 46500.0
Why are the results so different? I was expecting the result to be the same (or super close) because timestamp() resolves to a posix timestamp, which should be the same value for UTC for bst.
This is because, you have some assumptions wrong. Yes the
timestamp()returns the POSIX timestamp, but not of UTC time unless your system is configured with UTC time stamp.From the documentation ,
So, the function returns the timestamp, which is in accordance to the datetime object you hold. If the instance is in UTC, then you get POSIX timestamp for UTC.
Also mentioned clearly in docs
So, its kind of expected behavior in your case, as the BST is -1 hour from UTC.