diff options
author | Daniel Friesel <derf@finalrewind.org> | 2014-06-13 20:12:32 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2014-06-13 20:12:32 +0200 |
commit | aa86dd2d9cd15b2cccf0aa0285139aa56cd33f18 (patch) | |
tree | 0bdc1c0ad8e0ca3be9d6c9809bf9d98d5790611e /bin/icli | |
parent | 093190ff5ba96067c3b76c704f79e0560df8ad86 (diff) |
Determine system timezone using DateTime::Timezone
Diffstat (limited to 'bin/icli')
-rwxr-xr-x | bin/icli | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -12,6 +12,7 @@ use App::Icli::ConfigData; use Carp qw(croak); use DateTime; use DateTime::Format::Strptime; +use DateTime::TimeZone; use Getopt::Long qw/:config bundling/; use List::MoreUtils qw(any firstval); use POSIX qw(strftime); @@ -1044,12 +1045,14 @@ sub dispatch_command { sub action_on_host { my ($host) = @_; + my $tz = DateTime::TimeZone->new( name => 'local' ); + given ($action) { when ('downtime') { my ( $start, $end, $duration, $comment, @opts ) = @action_args; my $strp = DateTime::Format::Strptime->new( pattern => '%Y-%m-%dT%H:%M:%S', - time_zone => 'Europe/Berlin', # TODO read from system + time_zone => $tz->name, ); my $dt_start = $strp->parse_datetime($start); @@ -1095,12 +1098,14 @@ sub action_on_service { return; } + my $tz = DateTime::TimeZone->new( name => 'local' ); + given ($action) { when ('downtime') { my ( $start, $end, $duration, $comment, @opts ) = @action_args; my $strp = DateTime::Format::Strptime->new( pattern => '%Y-%m-%dT%H:%M:%S', - time_zone => 'Europe/Berlin', # TODO read from system + time_zone => $tz->name, ); my $dt_start = $strp->parse_datetime($start); @@ -1296,8 +1301,8 @@ Note: Acknowledgement of host problems is not yet supported. Schedule a non-triggered host or service (depending on the filter arguments) downtime. I<start> and I<stop> are timestamps and must be formatted as -YYYY-MM-DDTHH:MM:SS, where the "T" is literal. At this moment, they are always -interpreted in the Europe/Berlin timezone, this will change in the future. +YYYY-MM-DDTHH:MM:SS, where the "T" is literal. The timestamp is assumed to +be in the same time zone as the system running icli. If I<duration> is 0 (zero), a fixed downtime between I<start> and I<stop> is scheduled. Otherwise, a flexible downtime which will start between @@ -1539,16 +1544,14 @@ None. =item * DateTime::Format::Strptime +=item * DateTime::TimeZone + =item * Term::Size =back =head1 BUGS AND LIMITATIONS -When scheduling a downtime, the start and stop times are always interpreted -in the Europe/Berlin timezone. Also, the duration parameter is always -interpreted in hours. - It is probably not clear from the documentation when an action will operate on hosts and when on services. |