summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-12 10:16:42 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-12 10:16:42 -0700
commit2c496247f37b5e3c17147c219c34c0dec305a5ca (patch)
tree4c92f670d2c7249984abc17dc2fd6928f0684865 /scripts
parentd7fb3aa85e180af05b44ef88388b17deaf75d614 (diff)
parent15dc850144375cf53e85d6b5a2e9cbbca3eec3ca (diff)
downloadvyatta-op-2c496247f37b5e3c17147c219c34c0dec305a5ca.tar.gz
vyatta-op-2c496247f37b5e3c17147c219c34c0dec305a5ca.zip
Merge branch 'jenner' of 192.168.100.1:git/vyatta-op into jenner
Diffstat (limited to 'scripts')
-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";
+}