Subject: | ymd_hms() method - worth adding? |
I often find myself constructing a datetime string with, e.g.:
my $date = $dt->ymd . ' ' . $dt->hms;
I think a ymd_hms() method, which either returns the two concatenated by
a space, or, perhaps, more flexibly, returns a list of the date and
time, would be a good idea.
It would be especially useful in cases where you don't want to keep a
DateTime object, simply wanting the result of a calculation - for
example, you could use:
my $six_hours_ago = join ' ', DateTime->now->subtract( hours => 6
)->ymd_hms;
Calling ymd() and hms() individually means you'll need to assign the
datetime object to a var, at least temporarily, rather than just
capturing the end result.
It's just a thought of a minor addition which I, personally, would find
useful; whether it's universally useful enough to be worth adding to
DateTime, I don't know. I realise, of course, that there are other
ways, such as using strftime() or setting an appropriate Formatter.
If this was decided to be worthwhile adding, I'd be very happy to knock
up a patch if desired.