Zefram wrote:
Terrence Brannon wrote:
Yes, I would determine that aribtrary 1 second or nanosecond based on
the data in my database tables. a MySQL BETWEEN clause includes its
endpoints.

BETWEEN, then, is not the right way to express an open or half-open
interval.  If you're going to add anything to DT::Span, add a method that
generates the correct SQL expression, taking account of the openness of
each end of the interval.

-zefram


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'

$span = DateTime::Span->from_datetimes( start => $dt1, before => $dt2 );
# colname >= '2009-04-08 23:22:00' AND colname < '2009-04-09 23:22:00'

$span = DateTime::Span->from_datetimes( after => $dt1, before => $dt2 );
# colname > '2009-04-08 23:22:00' AND colname < '2009-04-09 23:22:00'

$span = DateTime::Span->from_datetimes( start => $dt1 );
# colname >= '2009-04-08 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)

Just my $0.02.

Cheers!
Rick Measham
--
Message  protected for iSite by MailGuard: e-mail anti-virus, anti-spam and 
content filtering.
http://www.mailguard.com.au


Reply via email to