title: Get local time zone name on Windows (Python 3.9 zoneinfo)
body: <p>Checking out the <a href="https://docs.python.org/3.9/library/zoneinfo.html#module-zoneinfo" rel="nofollow noreferrer"><code>zoneinfo</code></a> module in Python 3.9, I was wondering if it also offers a convenient option to retrieve the local time zone (OS setting) on Windows.</p>
  <p>On GNU/Linux, you can do</p>
  <pre><code>from datetime import datetime
  from zoneinfo import ZoneInfo
  
  naive = datetime(2020, 6, 11, 12)
  aware = naive.replace(tzinfo=ZoneInfo('localtime'))
  </code></pre>
  <p>but on Windows, that throws</p>
  <blockquote>
  <p>ZoneInfoNotFoundError: 'No time zone found with key localtime'</p>
  </blockquote>
  <p>so would I still have to use a third-party library? e.g.</p>
  <pre><code>import time
  import dateutil
  
  tzloc = dateutil.tz.gettz(time.tzname[time.daylight])
  aware = naive.replace(tzinfo=tzloc)
  </code></pre>
  <p>Since <code>time.tzname[time.daylight]</code> returns a localized name (German in my case, e.g. 'Mitteleuropäische Sommerzeit'), this doesn't work either:</p>
  <pre><code>aware = naive.replace(tzinfo=ZoneInfo(tzloc))
  </code></pre>
  <p>Any thoughts?</p>
  <hr />
  <p>p.s. to try this on Python &lt; 3.9, use <code>backports</code> (see also <a href="https://stackoverflow.com/a/62142350/10197418">this answer</a>):</p>
  <pre><code>pip install backports.zoneinfo
  pip install tzdata # needed on Windows
  </code></pre>