Subject: | One-off formatting |
Right now, its very awkward to format a DateTime object the way the user
want it formatted, as opposed to the creator. You have to...
my $old_formatter = $date->formatter;
$date->set_formatter($my_format);
my $string = "$date";
$date->set_formatter($old_foramtter);
Alternatively, clone it.
my $copy = $date->clone;
$date->set_formatter($my_format);
my $string = "$date";
Bleh. It would be very handy if you could do a one-off format
specifying the formatter same as with set_formatter.
my $string = $date->format_as($my_format);
This would allow you to pass around DateTime objects and have the using
code conveniently format them as needed rather than the creator trying
to predict the format.
This thread kicked it off:
http://www.nntp.perl.org/group/perl.datetime/2010/08/msg7573.html