[pve-devel] [PATCH common 2/3] CalendarEvent: add 'utc' flag to calendar specs

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Oct 31 10:54:17 CET 2018


Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 src/PVE/CalendarEvent.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/PVE/CalendarEvent.pm b/src/PVE/CalendarEvent.pm
index 7192712..9900c33 100644
--- a/src/PVE/CalendarEvent.pm
+++ b/src/PVE/CalendarEvent.pm
@@ -108,6 +108,9 @@ sub parse_calendar_event {
     };
 
     my @parts = split(/\s+/, $event);
+    my $utc = (@parts && uc($parts[-1]) eq 'UTC');
+    pop @parts if $utc;
+
 
     if ($parts[0] =~ m/$dowsel/i) {
 	my $dow_spec = shift @parts;
@@ -158,7 +161,7 @@ sub parse_calendar_event {
 	$m = [ sort { $a <=> $b } keys %$minutes_hash ];
     }
 
-    return { h => $h, m => $m, dow => [ sort keys %$dow_hash ]};
+    return { h => $h, m => $m, dow => [ sort keys %$dow_hash ], utc => $utc };
 }
 
 sub is_leap_year($) {
@@ -227,11 +230,12 @@ sub time_add_days($$) {
 }
 
 sub compute_next_event {
-    my ($calspec, $last, $utc) = @_;
+    my ($calspec, $last) = @_;
 
     my $hspec = $calspec->{h};
     my $mspec = $calspec->{m};
     my $dowspec = $calspec->{dow};
+    my $utc = $calspec->{utc};
 
     $last += 60; # at least one minute later
 
-- 
2.11.0





More information about the pve-devel mailing list