On Thu Mar 15 10:46:15 2007, DROLSKY wrote:
Show quoted text> On Thu Mar 08 14:06:37 2007, KRISHPL wrote:
> > Sure would be nice if I could use
> >
> > my $startdt = DateTime->now;
> >
> > if ($startdt lt "200702") {
> > warn "Your clock is *way* off";
> > }
>
> First, DateTime.pm does not have a date parser built-in, so we can't
> parse the string. That means that the string would be limited to ISO8601
> or some other format that DateTime.pm can output. Second, while this
I meant that when a DateTime object was an operator of a string comparison
([lg][te] eq ne cmp), it would stringify the DateTime object, not that the
string operator would try to parse the string as a date. Anyone who has
tried to print a DateTime object knows that it stringifies by default to
ISO8601 or to whatever the output formatter has been set to, so that seems
pretty unsurprising (in the technical sense).
Show quoted text> works pretty simply for dates without times, once you add times you
> start wanting to consider time zones, which makes the string more
> complicated.
Yup I believe that. I think that would be a bad idea too. Although,
another suggestion would be that DateTime be able to create a DateTime
object from its own default (iso8601) string output format. This would
provide a sort of self-containment (or mathematical 'closure' on the set of
its inputs and outputs), and wouldn't give the impression "This module is
willing to stringify to a common format, but not willing to accept that
same format". A handy side-effect of that is vastly simplified interchange
between DateTime<--stringify/parse-->iso8601<--select/insert-->databases
With perhaps a single s/ /T/ in one direction or the other. But this is an
issue for another bug.
Show quoted text> Honestly, I don't think this feature is worth the trouble, because it
> would be fairly limited, and it would fail to DWIM what mean people
might M.
Sure, no problem, I can work around it, but my idea of DWIM was that if a
DateTime stringifies in printf or doublequotes (which is really, really
handy, thanks -- in particular, I can use it directly in SQL server
statements), that it should stringify when presented to a string comparison
operator. I'd think a quick addendum to the docs would cover that.
------
The module also overloads stringification to use the iso8601() method,
which covers explicit string interpolation and string comparisons as well
as other forms of stringification.
------
Thanks for an excellent module. It's made some of the work I'm currently
doing simpler, and allows for clearer code with thorough error checking.