On Tuesday, January 14, 2003, at 07:24 PM, Dave Rolsky wrote:
I (and others) have suggested that:On Tue, 14 Jan 2003, Matthew Simon Cavalletto wrote:Ok, then what were you proposing moving out of (or not putting in) DateTime.pm in favor of putting it in a library.Agreed, strftime per se is Gregorian-centric.
- parser/formatter code should be broken up into multiple modules;
- this be done for all parsers/formatters, not just the "extra" ones.
Using strftime as an example, this suggests the following code:
package DateTime;
sub strftime { (shift)->format_string('strtime', @_) }
sub format_string {
my ($dt, $type, @fmt) = @_;
my $package = "DateTime::Format::$type";
$package->rdsec_to_string( $dt->as_rd_sec(), @fmt );
}
sub as_rd_sec {
my $dt = shift;
return( $dt->{ratadie}, $dt->{julsec} );
}
package DateTime::Format::strtime;
sub rdsec_to_string {
my ($class, $rd, $sec, $fmt) = @_;
# ... strftime logic...
return $string;
}
(Obviously the above is just an outline and would need real error handling and suchlike.)
-Simon
