Alexander Belopolsky added the comment: Your code as good as your timezone library, but you should realize that by discarding tzinfo you are making your "local_stamp" ambiguous.
I am not familiar with dateutil.tz, but pytz I believe uses some tricks to make sure astimezone() result remembers the isdst flag. If you API requires naive local datetime objects, you need to carry isdst flag separately if you want to disambiguate between 2014-04-06 02:00 NZST and 2014-04-06 02:00 NZDT. On top of that, you will not be able to use datetime.timestamp() method and will have to use time.mktime or whatever equivalent utility your timezone library provides. Note that I was against adding datetime.timestamp() for this specific reason: it is supposed to be inverse of datetime.fromtimestamp(), but since the later is not monotonic, no such inverse exists in the strict mathematical sense. See msg133039 in issue 2736. BTW, if you open a feature request to add isdst=-1 optional argument to datetime.timestamp(), you will have my +1. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22627> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com