#!/usr/bin/perl use strict; use warnings; use DateTime::Span; my $date1 = DateTime->new( year => 2002, month => 3, day => 11 ); my $date2 = DateTime->new( year => 2002, month => 5, day => 12 ); my $span = DateTime::Span->from_datetimes( start => $date1, end => $date2 ); my @timestamps; for my $month ( 1 .. 5) { my $date_x = DateTime->new( year => 2002, month => $month, day => 22 ); push @timestamps, $date_x; } for my $timestamp ( @timestamps ) { if ( $span->contains( $timestamp ) ) { print $timestamp->datetime, ' ', $span->contains( $timestamp ), " Yes!\n"; } else { print $timestamp->datetime, ' ', $span->contains( $timestamp ), " No!\n"; } }