[Vobject] Timezone Problems -- PLEASE HELP!

Jeffrey Harris jeffrey at osafoundation.org
Fri Aug 28 22:12:40 CDT 2009


Hi Keyton,

> First and foremost, thank you for sharing your VObject library with the
> world. It's a very nice way to handle these issues and I really
> appreciate its use.

Thanks!  Err, I mean you're welcome ;)

> The tzinfo class I'm using is the USTimeZone class from the Python site
> (http://docs.python.org/library/datetime.html#tzinfo-objects).

This was a head-scratcher for me, so I stepped through it and figured
out what's happening.

You need to remove the first part of the dst() method, the part that says:

if dt is None or dt.tzinfo is None:
  # An exception may be sensible here, in one or both cases.
  # It depends on how you want to treat them.  The default
  # fromutc() implementation (called by the default astimezone()
  # implementation) passes a datetime with dt.tzinfo is self.
  return ZERO

This was a really silly thing for them to include in the example.
There's no requirement in the actual documentation that dst be handed
something whose tzinfo class matches the original, and vobject's tzinfo
-> VTIMEZONE mechanism is currently handing naive datetimes to the
tzinfo class for testing.

Since the official example lists this code, vobject should fix this,
since I'm sure you won't be the last to use that example (as an aside,
I'd recommend using PyTZ or something like it, rather than that sample
code).  For now, though, just remove that counter-productive test and
you should be off and running...

Sincerely,
Jeffrey



More information about the VObject mailing list