• <tfoot id='X2T5z'></tfoot>

    1. <legend id='X2T5z'><style id='X2T5z'><dir id='X2T5z'><q id='X2T5z'></q></dir></style></legend>
    2. <small id='X2T5z'></small><noframes id='X2T5z'>

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

      • <bdo id='X2T5z'></bdo><ul id='X2T5z'></ul>

        pytz 等/GMT-5

        pytz and Etc/GMT-5(pytz 等/GMT-5)

              <tbody id='u2bWX'></tbody>
          1. <tfoot id='u2bWX'></tfoot>

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

            • <i id='u2bWX'><tr id='u2bWX'><dt id='u2bWX'><q id='u2bWX'><span id='u2bWX'><b id='u2bWX'><form id='u2bWX'><ins id='u2bWX'></ins><ul id='u2bWX'></ul><sub id='u2bWX'></sub></form><legend id='u2bWX'></legend><bdo id='u2bWX'><pre id='u2bWX'><center id='u2bWX'></center></pre></bdo></b><th id='u2bWX'></th></span></q></dt></tr></i><div id='u2bWX'><tfoot id='u2bWX'></tfoot><dl id='u2bWX'><fieldset id='u2bWX'></fieldset></dl></div>
              • <bdo id='u2bWX'></bdo><ul id='u2bWX'></ul>
                <legend id='u2bWX'><style id='u2bWX'><dir id='u2bWX'><q id='u2bWX'></q></dir></style></legend>
                  本文介绍了pytz 等/GMT-5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我无法理解Etc/GMT-5"时区与 pytz 中的 UTC 之间的转换.

                  I'm having trouble understanding the conversion between the "Etc/GMT-5" timezone and UTC in pytz.

                  >>> dt = datetime(2009, 9, 9, 10, 0) # September 9 2009, 10:00
                  >>> gmt_5 = pytz.timezone("Etc/GMT-5")
                  >>> gmt_5.localize(dt)
                  datetime.datetime(2009, 9, 9, 10, 0, tzinfo=<StaticTzInfo 'Etc/GMT-5'>)
                  

                  到目前为止一切都很好,但是我尝试将其转换为 UTC:

                  Everything is fine so far, but then I try to convert that to UTC:

                  >>> gmt_5.localize(dt).astimezone(pytz.utc)
                  datetime.datetime(2009, 9, 9, 5, 0, tzinfo=<UTC>)
                  

                  所以在我看来,当从 GMT-5 的 10:00 转换为 UTC 时,我得到了 05:00?我希望 pytz 给我 15:00.

                  So to me it seems that when converting from 10:00 in GMT-5 to UTC I get 05:00? I would expect pytz to give me 15:00 instead.

                  我错过了什么?

                  我已经确认美国/东部时区的时区转换正如我所期望的那样工作:

                  I have confirmed that timezone conversion for the US/Eastern timezone works just as I'd expect:

                  >>> eastern = pytz.timezone("US/Eastern")
                  >>> eastern.localize(dt)
                  datetime.datetime(2009, 9, 9, 10, 0, tzinfo=...) # Too long
                  >>> pytz.utc.normalize(eastern.localize(dt).astimezone(pytz.utc))
                  datetime.datetime(2009, 9, 9, 14, 0, tzinfo=<UTC>)
                  

                  编辑 2: 我已经确认,当我使用 Etc/GMT+5 时,我会得到 15:00,这是我期望从 Etc/GMT-5 得到的.这是一个 pytz 错误吗?

                  EDIT 2: I have confirmed that when I use Etc/GMT+5 I get 15:00, which is what I'd expect to get from Etc/GMT-5. Is this a pytz bug?

                  推荐答案

                  这显然是 POSIX 的事情.来自 维基百科:

                  This is apparently a POSIX thing. From Wikipedia:

                  为了符合 POSIX 风格,以Etc/GMT"开头的区域的符号与大多数人的预期相反.在这种样式中,GMT 以西的区域为正号,以东的区域为负号.

                  In order to conform with the POSIX style, those zones beginning with "Etc/GMT" have their sign reversed from what most people expect. In this style, zones west of GMT have a positive sign and those east have a negative sign.

                  这篇关于pytz 等/GMT-5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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% 就足够了)
                  <i id='sP0Gt'><tr id='sP0Gt'><dt id='sP0Gt'><q id='sP0Gt'><span id='sP0Gt'><b id='sP0Gt'><form id='sP0Gt'><ins id='sP0Gt'></ins><ul id='sP0Gt'></ul><sub id='sP0Gt'></sub></form><legend id='sP0Gt'></legend><bdo id='sP0Gt'><pre id='sP0Gt'><center id='sP0Gt'></center></pre></bdo></b><th id='sP0Gt'></th></span></q></dt></tr></i><div id='sP0Gt'><tfoot id='sP0Gt'></tfoot><dl id='sP0Gt'><fieldset id='sP0Gt'></fieldset></dl></div>

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

                        <tbody id='sP0Gt'></tbody>

                      • <bdo id='sP0Gt'></bdo><ul id='sP0Gt'></ul>
                        <tfoot id='sP0Gt'></tfoot>

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