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.

Having the OO there can be confusing. Consider the following code from the
docs:
  my $ical = DateTime::Format::ICal->new;
  my $dt = $ical->parse_datetime( '20030117T032900Z' );
  my $dur = $ical->parse_duration( '+P3WT4H55S' );

Reading that, because both lines call their methods on the same object I
assume the two methods are related.

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' );

but I would still argue against coding like that. There is no reason to make
the extra iCal objects except for clarity when reading.

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.



But my real preference would be thus:

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.

So how about:

<code>
   use DateTime::Format::iCal;
   use DateTime::Format;

   my $DateTime =
      new(DateTime::Format::iCal::parse_datetime('20030117T032900Z'));

   print $DateTime->format(DateTime::Format::iCal::format_datetime());
</code>

format_datetime() would return
- a string that is passed to strf or
- a code ref that the format command uses
Thus, if the format can use strf to format itself the format_datetime
returns such a string. Otherwise the coderef gets executed to return the
formated code.


--------------------------------------------------------
�� � � � � � There are 10 kinds of people:
�� those that understand binary, and those that don't.
--------------------------------------------------------
�� The day Microsoft makes something that doesn't suck
�� � is the day they start selling vacuum cleaners
--------------------------------------------------------


Reply via email to