Flávio Soibelmann Glock > DateTime-Set > DateTime::Span

Download:
DateTime-Set-0.3400.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source  

NAME ^

DateTime::Span - Datetime spans

SYNOPSIS ^

    use DateTime;
    use DateTime::Span;

    $date1 = DateTime->new( year => 2002, month => 3, day => 11 );
    $date2 = DateTime->new( year => 2003, month => 4, day => 12 );
    $set2 = DateTime::Span->from_datetimes( start => $date1, end => $date2 );
    #  set2 = 2002-03-11 until 2003-04-12

    $set = $set1->union( $set2 );         # like "OR", "insert", "both"
    $set = $set1->complement( $set2 );    # like "delete", "remove"
    $set = $set1->intersection( $set2 );  # like "AND", "while"
    $set = $set1->complement;             # like "NOT", "negate", "invert"

    if ( $set1->intersects( $set2 ) ) { ...  # like "touches", "interferes"
    if ( $set1->contains( $set2 ) ) { ...    # like "is-fully-inside"

    # data extraction 
    $date = $set1->start;           # first date of the span
    $date = $set1->end;             # last date of the span

DESCRIPTION ^

DateTime::Span is a module for handling datetime spans, otherwise known as ranges or periods ("from X to Y, inclusive of all datetimes in between").

This is different from a DateTime::Set, which is made of individual datetime points as opposed to a range. There is also a module DateTime::SpanSet to handle sets of spans.

METHODS ^

SUPPORT ^

Support is offered through the datetime@perl.org mailing list.

Please report bugs using rt.cpan.org

AUTHOR ^

Flavio Soibelmann Glock <fglock@gmail.com>

The API was developed together with Dave Rolsky and the DateTime Community.

COPYRIGHT ^

Copyright (c) 2003-2006 Flavio Soibelmann Glock. All rights reserved. This program is free software; you can distribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO ^

Set::Infinite

For details on the Perl DateTime Suite project please see http://datetime.perl.org.

syntax highlighting: