parsing intervals lose the UTC information

Issue #22 invalid
Former user created an issue

Parsing any of the following examples loses the time zone information:

  • "2050-03-01T13:00:00Z/2050-05-11T15:30:00Z"
  • "2050-03-01T13:00:00Z/PT10H"

I am using the following code:

import aniso8601
from aniso8601.builder import RelativeTimeBuilder

aniso8601.parse_interval(when, builder=RelativeTimeBuilder)

And I get datetime.datetime objects without tzinfo. I guess this is a bug.

Comments (2)

  1. Brandon Nielsen repo owner

    What version are you using? I can't reproduce:

    >>> import aniso8601
    >>> from aniso8601.builder import RelativeTimeBuilder
    >>> aniso8601.parse_interval('2050-03-01T13:00:00Z/2050-05-11T15:30:00Z', builder=RelativeTimeBuilder)
    (datetime.datetime(2050, 3, 1, 13, 0, tzinfo=+0:00:00 UTC), datetime.datetime(2050, 5, 11, 15, 30, tzinfo=+0:00:00 UTC))
    >>> aniso8601.parse_interval('2050-03-01T13:00:00Z/PT10H', builder=RelativeTimeBuilder)
    (datetime.datetime(2050, 3, 1, 13, 0, tzinfo=+0:00:00 UTC), datetime.datetime(2050, 3, 1, 23, 0, tzinfo=+0:00:00 UTC))
    
  2. Log in to comment