You have not made your code easy enough to test each pair of date-time string & format-to-parse (by using a list of either array references or hash references).

Do you have issues with both *::Strptime & *::Recurrence? If so, could you please address them in separate threads?

About *::Strptime output as listed, I do not see anything wrong as far as values of $lodt, $hidt, $dt1, & $dt2 are concerned. What am I missing?

About *:Recurrence, as I understood the documentation, each event happens at the start of the interval. If it is "daily", then the even will start at 00:00:00. It can be changed to a different time via options of "hours" & "minutes".

# vim: ts=2 sts=2 sw=2 sr ai nu et: # use strict; use warnings; use DateTime; use DateTime::Format::Strptime; use DateTime::Event::Recurrence; # Current time. my $dtnow = DateTime->now( time_zone => DateTime::TimeZone->new( name +=> 'local' ) ); showtime( $dtnow, q[now dt: ] ); # Various date-time strings & formats to parse. my $dt_format = '%d/%m/%Y %I:%M:%S %p' ; my $start = "18/03/2019 10:12:53 am" ; my @end = ( [ "24/03/2019 3:15:00 pm" , $dt_format ] , [ "24/03/2019 03:15:00 pm" , $dt_format ] , [ "24/03/2019 15:15:00 pm" , '%d/%m/%Y %H:%M:%S %p' ] , [ "24/03/2019 15:15:00" , '%d/%m/%Y %H:%M:%S' ] ); my $start_dt = make_datetime( $start , $dt_format ); showtime( $start_dt , q[start dt: ] ); print "\n"; for my $dt_pair ( @end ) { my $string = $dt_pair->[0]; my $dt = make_datetime( @{ $dt_pair } ); showtime( $dt , sprintf q[end dt (%s) : ] , $string ); } print "\n"; # Recurring event. my $end = $end[ int rand @end ]; my $end_dt = make_datetime( @{ $end } ); my ( $hour , $min ) = ( 11 , 23 ); my $day_ev = DateTime::Event::Recurrence->daily( 'hours' => $hour , 'm +inutes' => $min ); my @set = $day_ev->as_list( 'start' => $start_dt , 'end' => $end_dt ); printf "Recurring event at %d:%d from %s to %s ...\n" , $hour , $min , $start_dt->iso8601() , $end_dt->iso8601() ; showtime( $_ , q[ !! ] ) for @set ; print "\n"; exit; sub make_datetime { my ( $dt , $format ) = @_; return DateTime::Format::Strptime ->new( on_error => 'croak' , time_zone => 'local' , pattern => $format ) ->parse_datetime( $dt ); } sub showtime { my ( $dt , $label ) = @_; $label ||= ''; print $label , $dt->iso8601() , "\n"; return; } __END__
now dt: 2019-03-27T02:46:41 start dt: 2019-03-18T10:12:53 end dt (24/03/2019 3:15:00 pm) : 2019-03-24T15:15:00 end dt (24/03/2019 03:15:00 pm) : 2019-03-24T15:15:00 end dt (24/03/2019 15:15:00 pm) : 2019-03-24T15:15:00 end dt (24/03/2019 15:15:00) : 2019-03-24T15:15:00 Recurring event at 11:23 from 2019-03-18T10:12:53 to 2019-03-24T15:15: +00 ... !! 2019-03-18T11:23:00 !! 2019-03-19T11:23:00 !! 2019-03-20T11:23:00 !! 2019-03-21T11:23:00 !! 2019-03-22T11:23:00 !! 2019-03-23T11:23:00 !! 2019-03-24T11:23:00

In reply to Re^2: DateTime::Format::Strptime Parsing Seems to have a Problem? by parv
in thread DateTime::Format::Strptime Parsing Seems to have a Problem? by ozboomer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.