use warnings;
use Data::Dumper;
use Time::Local;
+use PVE::JSONSchema;
# Note: This class implements a parser/utils for systemd like calender exents
# Date specification is currently not implemented
sat => 6,
};
+PVE::JSONSchema::register_format('pve-calendar-event', \&pve_verify_calendar_event);
+sub pve_verify_calendar_event {
+ my ($text, $noerr) = @_;
+
+ eval { parse_calendar_event($text); };
+ if (my $err = $@) {
+ return undef if $noerr;
+ die "invalid calendar event '$text'\n";
+ }
+ return $text;
+}
+
# The parser.
# returns a $calspec hash which can be passed to compute_next_event()
sub parse_calendar_event {
if ($matchall_hours) {
$h = '*';
} else {
- $h = [ sort keys %$hours_hash ];
+ $h = [ sort { $a <=> $b } keys %$hours_hash ];
}
if ($matchall_minutes) {
$m = '*';
} else {
- $m = [ sort keys %$minutes_hash ];
+ $m = [ sort { $a <=> $b } keys %$minutes_hash ];
}
return { h => $h, m => $m, dow => [ sort keys %$dow_hash ]};