• <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

      时间:2023-07-03

          • <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何确定 DST 何时在 Python 中的特定位置开始或结束? 下一篇:Python - 在UTC中获取时区感知当前时间的最简单和最连贯的方法?

                相关文章

                  <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>
                  1. <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'>