How do I get the UTC time of “midnight” for a given timezone?
I think you can shave off a few method calls if you do it like this: >>> from datetime import datetime >>> datetime.now(pytz.timezone(“Australia/Melbourne”)) \ .replace(hour=0, minute=0, second=0, microsecond=0) \ .astimezone(pytz.utc) BUT… there is a bigger problem than aesthetics in your code: it will give the wrong result on the day of the switch to or … Read more