+package Mojo::IOLoop::Repeating;
+use Mojo::Base 'Mojo::EventEmitter';
+use Mojo::Loader qw(load_class);
+use Date::Calc qw(Today_and_Now Add_Delta_DHMS Delta_DHMS Date_to_Time);
+has events => sub { [] };
+ my @now = Today_and_Now;
+ my (@offset) = Delta_DHMS(@start, @now);
+ $offset[-1] = 60 - $offset[-1];
+ my @next = Add_Delta_DHMS(@now, @offset);
+ my $now = Date_to_Time(@now);
+ my $next = Date_to_Time(@next);
+ my $seconds = $next - $now;
+ foreach my $event (@{ $self->events }) {
+ my ($line, $pkg, $method) = @{ $event };
+ if (my $e = load_class($pkg)) {
+ die ref $e ? "Exception: $e" : 'Not found!';
+ my $time_cron = Time::Crontab->new($line);
+ if ($time_cron->match($time)) {
+ &{ "${pkg}::$method" };
+ Mojo::IOLoop->next_tick(sub {
+ warn("seconds: $seconds");
+ my $repeating = \&repeating;
+ # Mojo::IOLoop->timer($seconds => \&repeating);
+ Mojo::IOLoop->timer($seconds => sub {
+ my $repeating = \&repeating;
+ Mojo::IOLoop->timer(1 => sub {
+ Mojo::IOLoop->start unless Mojo::IOLoop->is_running;