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: 94001
Status: rejected
Priority: 0/
Queue: DateTime

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

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



Subject: datetime() could take a separator param like e.g. dmy()
dmy() / hms() accept a parameter to indicate the separator to override the default, e.g. dmy('/') I think datetime() should accept a parameter to override the default "T" separator, so e.g. datetime(' ') would give '2014-03-19 10:23:00' instead of '2014-03-19T10:23:00' - simply because saying $dt->datetime(' ') seems nicer than e.g. join ' ', $dt->dmy, $dt->hms; Thoughts? Would be happy to submit a patch if this was welcomed.
On Wed Mar 19 06:25:45 2014, BIGPRESH wrote: Show quoted text
> dmy() / hms() accept a parameter to indicate the separator to override > the default, e.g. dmy('/') > > I think datetime() should accept a parameter to override the default > "T" separator, so e.g. datetime(' ') would give '2014-03-19 10:23:00' > instead of '2014-03-19T10:23:00' - simply because saying $dt-
> >datetime(' ') seems nicer than e.g. join ' ', $dt->dmy, $dt->hms;
> > Thoughts? > > Would be happy to submit a patch if this was welcomed.
Well, by that logic it should accept three parameters, for date separator, time separator and the separator between date & time. That could be ok, but you can already get any format you want out of format_cldr() and strftime(), so I'm not sure if this is really necessary.
Subject: Re: [rt.cpan.org #94001] datetime() could take a separator param like e.g. dmy()
Date: Wed, 19 Mar 2014 14:46:25 +0000
To: bug-DateTime [...] rt.cpan.org
From: David Precious <davidp [...] preshweb.co.uk>
On Wed, 19 Mar 2014 10:32:38 -0400 "Dave Rolsky via RT" <bug-DateTime@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=94001 > > > On Wed Mar 19 06:25:45 2014, BIGPRESH wrote:
> > dmy() / hms() accept a parameter to indicate the separator to > > override the default, e.g. dmy('/') > > > > I think datetime() should accept a parameter to override the default > > "T" separator, so e.g. datetime(' ') would give '2014-03-19 > > 10:23:00' instead of '2014-03-19T10:23:00' - simply because saying > > $dt-
> > >datetime(' ') seems nicer than e.g. join ' ', $dt->dmy, $dt->hms;
> > Well, by that logic it should accept three parameters, for date > separator, time separator and the separator between date & time. > > That could be ok, but you can already get any format you want out of > format_cldr() and strftime(), so I'm not sure if this is really > necessary.
Hmm, good point - I guess accepting a parameter to set the separator between the date and time, but not letting you supply the separator to use in the date or the time would seem odd, too. Perhaps just using e.g. DateTime::Format::MySQL is the right approach, rather than cluttering DateTime with extra stuff for shorthand. It pains me that $datetime->datetime() is *so* close to what I want, but not quite, and that there's no way to get it to do what I want - but at the end of the day I'm looking for a format, which can be obtained using a DateTime::Format::* module that exists fairly easily, or saying $datetime->strftime('%F %T'), and there's a good case for keeping stuff for specific formats out of DateTime itself and in formatter classes. So, yeah, fair point. Cheers!