• <bdo id='goYun'></bdo><ul id='goYun'></ul>
      <legend id='goYun'><style id='goYun'><dir id='goYun'><q id='goYun'></q></dir></style></legend>
      <tfoot id='goYun'></tfoot>
    1. <small id='goYun'></small><noframes id='goYun'>

      <i id='goYun'><tr id='goYun'><dt id='goYun'><q id='goYun'><span id='goYun'><b id='goYun'><form id='goYun'><ins id='goYun'></ins><ul id='goYun'></ul><sub id='goYun'></sub></form><legend id='goYun'></legend><bdo id='goYun'><pre id='goYun'><center id='goYun'></center></pre></bdo></b><th id='goYun'></th></span></q></dt></tr></i><div id='goYun'><tfoot id='goYun'></tfoot><dl id='goYun'><fieldset id='goYun'></fieldset></dl></div>
    2. 如何获取 pytz 时区的通用名称,例如.美国/纽约的 EST/EDT

      How to get the common name for a pytz timezone eg. EST/EDT for America/New_York(如何获取 pytz 时区的通用名称,例如.美国/纽约的 EST/EDT)

          • <small id='w4bKC'></small><noframes id='w4bKC'>

            <legend id='w4bKC'><style id='w4bKC'><dir id='w4bKC'><q id='w4bKC'></q></dir></style></legend>

              <tfoot id='w4bKC'></tfoot>
              <i id='w4bKC'><tr id='w4bKC'><dt id='w4bKC'><q id='w4bKC'><span id='w4bKC'><b id='w4bKC'><form id='w4bKC'><ins id='w4bKC'></ins><ul id='w4bKC'></ul><sub id='w4bKC'></sub></form><legend id='w4bKC'></legend><bdo id='w4bKC'><pre id='w4bKC'><center id='w4bKC'></center></pre></bdo></b><th id='w4bKC'></th></span></q></dt></tr></i><div id='w4bKC'><tfoot id='w4bKC'></tfoot><dl id='w4bKC'><fieldset id='w4bKC'></fieldset></dl></div>
              • <bdo id='w4bKC'></bdo><ul id='w4bKC'></ul>
                  <tbody id='w4bKC'></tbody>
                本文介绍了如何获取 pytz 时区的通用名称,例如.美国/纽约的 EST/EDT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                给定特定用户的 pytz 时区(从他的偏移量计算),我想显示该时区的通用名称.我假设人们更习惯于看到 ESTPST,而不是像 America/NewYork 这样的拼写.

                Given a pytz timezone for a particular user(calculated from his offset), i want to display the common name for that timezone. I'm assuming people are more accustomed to seeing EST or PST instead of spelled out like America/NewYork.

                pytz 是否在某处给了我这些标准名称,还是我必须通过表格手动执行此操作?这可能会变得混乱,因为例如某个季节的地点是美国东部标准时间,而其他地点则转向显示美国东部时间.

                Does pytz give me those standard names somewhere, or will i have to manually do this via a table? This could potentially get messy, since for example places are EST in a season and shift to showing EDT during others.

                推荐答案

                给定特定用户的 pytz 时区(从他的偏移量计算),我想显示该时区的通用名称.我假设人们更习惯于看到 EST 或 PST,而不是像 America/NewYork 这样拼写出来.

                Given a pytz timezone for a particular user(calculated from his offset), i want to display the common name for that timezone. I'm assuming people are more accustomed to seeing EST or PST instead of spelled out like America/NewYork.

                如果您需要从使用 pytz 本地化的 datetime 对象派生...

                If you need this derived from a datetime object localized with pytz...

                >>> import pytz as tz
                >>> from datetime import datetime as dt
                >>> CT = tz.timezone('America/Chicago')
                >>>
                >>> summer_day = dt(2010, 7, 4, 0, 1, 1)
                >>> bar = CT.localize(summer_day, is_dst=None)
                >>> bar.tzname()
                'CDT'
                >>>
                >>> christmas = dt(2010, 12, 25, 0, 1, 1)
                >>> foo = CT.localize(christmas, is_dst=None)
                >>> foo.tzname()
                'CST'
                >>> 
                

                这篇关于如何获取 pytz 时区的通用名称,例如.美国/纽约的 EST/EDT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                env: python: No such file or directory(env: python: 没有这样的文件或目录)
                How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)

                    <tbody id='K4STs'></tbody>

                    <tfoot id='K4STs'></tfoot>

                      <legend id='K4STs'><style id='K4STs'><dir id='K4STs'><q id='K4STs'></q></dir></style></legend>
                        <bdo id='K4STs'></bdo><ul id='K4STs'></ul>
                        • <i id='K4STs'><tr id='K4STs'><dt id='K4STs'><q id='K4STs'><span id='K4STs'><b id='K4STs'><form id='K4STs'><ins id='K4STs'></ins><ul id='K4STs'></ul><sub id='K4STs'></sub></form><legend id='K4STs'></legend><bdo id='K4STs'><pre id='K4STs'><center id='K4STs'></center></pre></bdo></b><th id='K4STs'></th></span></q></dt></tr></i><div id='K4STs'><tfoot id='K4STs'></tfoot><dl id='K4STs'><fieldset id='K4STs'></fieldset></dl></div>

                          <small id='K4STs'></small><noframes id='K4STs'>