summaryrefslogtreecommitdiff
path: root/scripts/vyatta-gettime.pl
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-12 10:13:44 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-12 10:16:17 -0700
commit15dc850144375cf53e85d6b5a2e9cbbca3eec3ca (patch)
tree10fd217658749dbf6c80b5d07e50e50cd168c037 /scripts/vyatta-gettime.pl
parent0f26d05ff7f1b49d01449774b0add799024bde7e (diff)
downloadvyatta-op-15dc850144375cf53e85d6b5a2e9cbbca3eec3ca.tar.gz
vyatta-op-15dc850144375cf53e85d6b5a2e9cbbca3eec3ca.zip
Add show shutdown
Bug 4217 Add show shutdown, try and determine time.
Diffstat (limited to 'scripts/vyatta-gettime.pl')
-rwxr-xr-xscripts/vyatta-gettime.pl44
1 files changed, 44 insertions, 0 deletions
diff --git a/scripts/vyatta-gettime.pl b/scripts/vyatta-gettime.pl
new file mode 100755
index 0000000..ae0824b
--- /dev/null
+++ b/scripts/vyatta-gettime.pl
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+#
+# Module: vyatta-gettime.pl
+#
+# **** License ****
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# This code was originally developed by Vyatta, Inc.
+# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
+# All Rights Reserved.
+#
+# Author: Stephen Hemminger
+# Date: March 2009
+# Description: Script to read time for shutdown
+#
+# **** End License ****
+#
+
+use strict;
+use warnings;
+use Date::Format;
+
+sub gettime {
+ my $t = shift;
+
+ return time2str( "%R", time ) if ( $t eq 'now' );
+ return $t if ( $t =~ /^[0-9]+:[0-9]+/ );
+ $t = substr( $t, 1 ) if ( $t =~ /^\+/ );
+ return time2str( "%R", time + ( $_ * 60 ) ) if ( $t =~ /^[0-9]+/ );
+
+ die "invalid time format: $t\n";
+}
+
+# decode shutdown time
+for (@ARGV) {
+ print gettime($_), "\n";
+}