Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 74186
Status: rejected
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: davidp [...] preshweb.co.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



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.
On Fri Jan 20 13:14:03 2012, BIGPRESH wrote: Show quoted text
> 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 Show quoted text
> 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 Show quoted text
> 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 Show quoted text
> up a patch if desired.
I think it's already easy enough to do this with stftime() and format_cldr().