… | |
… | |
718 | (that is, the lowest time value larger than or equal to to the second |
718 | (that is, the lowest time value larger than or equal to to the second |
719 | argument). It will usually be called just before the callback will be |
719 | argument). It will usually be called just before the callback will be |
720 | triggered, but might be called at other times, too. |
720 | triggered, but might be called at other times, too. |
721 | |
721 | |
722 | This can be used to create very complex timers, such as a timer that |
722 | This can be used to create very complex timers, such as a timer that |
723 | triggers on each midnight, local time (actually 24 hours after the last |
723 | triggers on each midnight, local time (actually one day after the last |
724 | midnight, to keep the example simple. If you know a way to do it correctly |
724 | midnight, to keep the example simple): |
725 | in about the same space (without requiring elaborate modules), drop me a |
|
|
726 | note :): |
|
|
727 | |
725 | |
728 | my $daily = EV::periodic 0, 0, sub { |
726 | my $daily = EV::periodic 0, 0, sub { |
729 | my ($w, $now) = @_; |
727 | my ($w, $now) = @_; |
730 | |
728 | |
731 | use Time::Local (); |
729 | use Time::Local (); |
732 | my (undef, undef, undef, $d, $m, $y) = localtime $now; |
730 | my (undef, undef, undef, $d, $m, $y) = localtime $now; |
733 | 86400 + Time::Local::timelocal 0, 0, 0, $d, $m, $y |
731 | Time::Local::timelocal_nocheck 0, 0, 0, $d + 1, $m, $y |
734 | }, sub { |
732 | }, sub { |
735 | print "it's midnight or likely shortly after, now\n"; |
733 | print "it's midnight or likely shortly after, now\n"; |
736 | }; |
734 | }; |
737 | |
735 | |
738 | =back |
736 | =back |