use IO::Async::Timer::Absolute;
use POSIX qw( mktime );
use IO::Async::Loop;
my $loop = IO::Async::Loop->new;
my @time = gmtime;
my $timer = IO::Async::Timer::Absolute->new(
time => mktime( 0, 0, 0, $time[3]+1, $time[4], $time[5] ),
on_expire => sub {
print "It's midnight\n";
$loop->stop;
},
);
$loop->add( $timer );
$loop->run;
For a "Timer" object that waits for a delay relative to the time it is started, see instead IO::Async::Timer::Countdown.
Once constructed, the timer object will need to be added to the "Loop" before it will work.
Unlike other timers, it does not make sense to "start" this object, because its expiry time is absolute, and not relative to the time it is started.