Re: RFC:: DateTime::Span::Common

[email protected] ("Flavio S. Glock")
Newsgroups perl.datetime
Message-ID <[email protected]>
2009/4/8 Rick Measham <[email protected]>:
> Sounds like a job for DateTime::Format::MySQL ..
>
> $span = DateTime::Span->from_datetimes( start => $dt1, end => $dt2 );
> print DateTime::Format::MySQL->format_span( $span, 'colname' );
> # colname >= '2009-04-08 23:22:00' AND colname <= '2009-04-09 23:22:00'
[...]
> And could be extended to SpanSets too:
> $spanset = DateTime::SpanSet->from_spans( spans => [ $dt_span, $dt_span ] );
> # (colname >= '2009-04-08 23:22:00' AND colname < '2009-04-09 23:22:00') OR
> (colname >= '2009-05-08 23:22:00' AND colname < '2009-05-09 23:22:00')
>
> (Of course, this couldn't be expected to work on infinite or even large
> spansets)

Good idea!

Please use 'format_period' instead of 'format_span' - format_period()
is used by DateTime::Format::ICal API.

format_recurrence() is doable too. DateTime::Event::Recurrence stores
some hints that make stringification possible in several cases.

- Flavio S. Glock
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.