From maxm at mxm.dk Wed Mar 15 21:09:19 2006 From: maxm at mxm.dk (Max M) Date: Wed Mar 15 21:08:46 2006 Subject: [icalendar-checkins] r19617 - in iCalendar/trunk: doc src/icalendar In-Reply-To: <20051107204202.A7A5327B4E@code1.codespeak.net> References: <20051107204202.A7A5327B4E@code1.codespeak.net> Message-ID: <4418746F.7070405@mxm.dk> dreamcatcher@codespeak.net wrote: >Author: dreamcatcher >Date: Mon Nov 7 21:41:55 2005 >New Revision: 19617 > >- Changed UTC tzinfo to a singleton so the same one is used everywhere > > Hi Sidney, I find the above behaviour confusing. The problem is the difference here: "FixedOffset()", "LocalTimezone()", "UTC". Two timezones are classes and a single one is an object. You changed UTC from a class to an object to make a singleton out of it. Why was that necessary? Do you use it for equality comparison somewhere? If it is only for a minor speedup, I think that will be offset by programmers spending time figuring out the difference. In that case I would have found it better if you made an instance an called it "utc" or something like that. class UTC(tzinfo): """UTC tzinfo subclass""" def utcoffset(self, dt): return ZERO def tzname(self, dt): return "UTC" def dst(self, dt): return ZERO utc = UTC() # singleton Is there any major complaints if i change it to that? It *is* only a 0.11 version, so backwards incompatible changes should be ok. The fix is also easy for packages using it. from icalendar import utc as UTC A backwards compatible fix would be to add a call method to the class: def __call__(self): "FixedOffset and LocalTimezone are both classes." pass But that feels a bit hackish. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96