title: How do I get the UTC time of "midnight" for a given timezone?
body: <p>The best I can come up with for now is this monstrosity:</p>
  
  <pre><code>&gt;&gt;&gt; datetime.utcnow() \
  ...   .replace(tzinfo=pytz.UTC) \
  ...   .astimezone(pytz.timezone("Australia/Melbourne")) \
  ...   .replace(hour=0,minute=0,second=0,microsecond=0) \
  ...   .astimezone(pytz.UTC) \
  ...   .replace(tzinfo=None)
  datetime.datetime(2008, 12, 16, 13, 0)
  </code></pre>
  
  <p>I.e., in English, get the current time (in UTC), convert it to some other timezone, set the time to midnight, then convert back to UTC.</p>
  
  <p>I'm not just using now() or localtime() as that would use the server's timezone, not the user's timezone.</p>
  
  <p>I can't help feeling I'm missing something, any ideas?</p>