Why does python parse dates differently on Ubuntu and MacOS?
Question: I've got some code that inexplicably works differently on Ubuntu and MacOS
compiles of the same python version. Any explanation or workaround would be
welcome.

First, the setup on Ubuntu Python. The machine is running in UTC. Using PST in
the time string fails, but changing PST to UTC it works fine.

    
    
    Python 2.7.3 (default, Sep 26 2013, 20:03:06) 
    [GCC 4.6.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from datetime import datetime
    >>> date_str = 'Thu Jan 1 00:32:36 PST 2015'
    >>> now = datetime.strptime(date_str, '%a %b %d %H:%M:%S %Z %Y')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.7/_strptime.py", line 325, in _strptime
        (data_string, format))
    ValueError: time data 'Thu Jan 1 00:32:36 PST 2015' does not match format '%a %b %d %H:%M:%S %Z %Y'
    >>> date_str = 'Thu Jan 1 00:32:36 UTC 2015'
    >>> now = datetime.strptime(date_str, '%a %b %d %H:%M:%S %Z %Y')
    >>> 
    

Now on MacOS (running in PDT), python there doesn't care what timezone is
specified and works with any timezone:

    
    
    Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
    [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from datetime import datetime
    >>> date_str = 'Thu Jan  1 00:32:36 GMT 2015'
    >>> now = datetime.strptime(date_str, '%a %b %d %H:%M:%S %Z %Y')
    >>> 
    

The versions of GCC are different and the datestamps of python 2.7.3 are
different, but this seems like pretty straightforward functionality that
wouldn't have OS dependencies.

I saw bugs like this <http://bugs.python.org/issue8957> that were loosely
related. Is this better asked as a bug report on python.org?


Answer: The documentation says that [%Z is inherently platform
specific](https://docs.python.org/2/library/time.html):

> Support for the %Z directive is based on the values contained in tzname and
> whether daylight is true. Because of this, it is platform-specific except
> for recognizing UTC and GMT which are always known (and are considered to be
> non-daylight savings timezones).

