On Thu, 13 Feb 2003, Rick Measham wrote: > On 13/2/03 9:05 am, Dave Rolsky at [EMAIL PROTECTED] spake thus: > > This is why there will be a DateTime::Format::ISO8601 module for parsing > > ISO formats ;) > > Dave, having worked with the DateTime::Format::iCal module, and with its > innards, I wonder if it should be an OO module or not. There is currently no > reason to create a DateTime::Format::iCal object except as a way to call the > methods in the module. The methods there just return a string based on a > passed-in DateTime object or they return a DateTime object.
The problem is that in the future there may be format modules for which parameters need to be set on a per-object basis. For example, a "human language" parser might take an argument to set the language. > For clarity, the above should be: > my $ical_datetime = DateTime::Format::ICal->new; > my $dt = $ ical_datetime->parse_datetime( '20030117T032900Z' ); > > my $ical_duration = DateTime::Format::ICal->new; > my $dur = $ ical_duration->parse_duration( '+P3WT4H55S' ); How is that clearer? > If we want to keep it OO would be that DateTime::Format::ICal->new replaces > parse_datetime and takes an iCal date/time string. It then returns a > DateTime::Format::ICal object whose methods are all inherited from DateTime. No, no, no. We're not going to have lots and lots of DateTime.pm subclasses. The only reason to subclass DateTime.pm is to change the _implementation_, not to add formatting or parsing features. What if you need to parse iCal and output ISO8601? What subclass would you use? > I think this module really should just contain subs rather than methods. I > imagine the reason for it not returning its own object is so that different > formats can be input and output. See above. I think some formats will need per-object parameters. > <code> > use DateTime::Format::iCal; > use DateTime::Format; > > my $DateTime = > new(DateTime::Format::iCal::parse_datetime('20030117T032900Z')); What is new()? A function? Should that be DateTime->new? > print $DateTime->format(DateTime::Format::iCal::format_datetime()); > </code> I don't think this code is easier to understand, anyway. Yes, the object for the iCal format is pointless, but I'd like to have the same(-ish) API for all format modules. Also, I don't really like the idea of some of the DateTime suite modules being OO, and others functional. That's too awkward. -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/