Skip to content

parser.parse does not apply time zone to date if ignoretz is True and tzinfos is given #80

@pajusmar

Description

@pajusmar

Quoting the docs:

tzinfos – A time zone, to be applied to the date, if ignoretz is True. This can be either a subclass of tzinfo, a time zone string or an integer offset.

I hope that i'm not misinterpreting docs, but i would expect parse to return aware datetime.

Python 2.7.8 (default, Oct 20 2014, 15:05:19) 
Type "copyright", "credits" or "license" for more information.

IPython 2.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import dateutil

In [2]: dateutil.__version__
Out[2]: '2.4.2'

In [3]: from dateutil.parser import parse

In [4]: parse("Sat Oct 11 17:13:46 UTC 2003", ignoretz=True, tzinfos='Europe/Tallinn')
Out[4]: datetime.datetime(2003, 10, 11, 17, 13, 46)

Instead it returns naive datetime.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions