The time_machine module in python keeps setting a time that is one day earlier than the date that I set.
I must be missing something obvious!
Here's an example of a simple program showing the discrepancy:
import time_machine
import datetime as dt
def main():
print(timemachine())
print(today_time())
def timemachine():
with time_machine.travel(dt.datetime(2024, 7, 24), tick = False):
return dt.date.today().isoformat()
def today_time():
return dt.datetime.today()
if __name__ == "__main__":
main()
Output:
2024-07-23 -> That's the output for dt.datetime(2024, 7, 24), which is a day earlier.
2024-07-25 11:38:30.354514 -> That's the output for today's date, to ensure that there's nothing wrong with datetime.