[Zope3-dev] Re: date parsing: explicit is better

Shane Hathaway shane@zope.com
Fri, 22 Nov 2002 12:41:50 -0500


Stephan Richter wrote:
> On Friday 22 November 2002 10:05, Shane Hathaway wrote:
> 
>>Ooh, ooh, I smell a new method for the locale service.
>>ILocaleService.parseDate() or somesuch would return a date given a text
>>string, raising an error if it's ambiguous.  This would even let us deal
>>with non-US month names, as in "05-OUT-02" (Portuguese), or whatever
>>unusual conventions people use around the world.
> 
> 
> Right, but I think the problem is much broader. What we really need is a way 
> of saying: For the German Locale, give me the long version datetime 
> formatter. This formatter can then be used to (i) parse and (ii) create a 
> datetime object. This is the way Java approaches the issue, and I think it is 
> the best possible way and it covers all problems. 
> For example you could also say: Give me the currency representation for the 
> German Locale. 

Are you sure we need that?  I would expect that we only need methods 
like "parse this date string in the configured locale, returning a 
datetime" and "format this currency in the configured locale".  There 
might be a "MultipleLocaleService", as you suggest, but that's distinct 
from the LocaleService.

The LocaleService might *use* your MultipleLocaleService, but it doesn't 
have to.  To start out, it could blindly assume a hybrid of US and 
European conventions, later becoming smarter.  This makes writing the 
basic locale service a lot easier.

Shane