New submission from B. Liu: In Python 2.7, the following works:
import datetime ZERO = timedelta(0) class UTC(datetime.tzinfo): """UTC""" # can be configured here def utcoffset(self, dt): return ZERO def tzname(self, dt): return "UTC" def dst(self, dt): return ZERO def extraMethod(self): return "here is an extra method" utc = UTC() epoch = datetime.datetime.utcfromtimestamp(0) print datetime.datetime.fromtimestamp(epoch, utc) But, the following does not work: import datetime ZERO = timedelta(0) class UTC(datetime.tzinfo): """UTC""" # can be configured here def utcoffset(self, dt): return ZERO def tzname(self, dt): return "UTC" def dst(self, dt): return ZERO def extraMethod(self): return "here is an extra method" utc = UTC() epoch = datetime.datetime.utcfromtimestamp(0) print datetime.datetime.fromtimestamp(epoch, utc) The difference is that there is a space after the class line. Is this an issue with grammar or some issue with the library's C code? If it is an issue with grammar, I appear to have not run into this issue with non-datetime-related code. If this not an issue, please correct me. Thanks! Brian ---------- components: Library (Lib) files: bug.py messages: 281867 nosy: bzliu94 priority: normal severity: normal status: open title: tzinfo class spacing bug Added file: http://bugs.python.org/file45670/bug.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28819> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com