public
Description: My personal script stash
Homepage: http://github.com/melo/scripts
Clone URL: git://github.com/melo/scripts.git
Search Repo:
Added usage, and --help/-? switches to x-datetime-converter

Signed-off-by: Pedro Melo <melo@simplicidade.org>
melo (author)
Sat May 03 03:57:24 -0700 2008
commit  17ce93555ac4e98d06a0852a23e55c97dc59f1aa
tree    f8a3c074f4ef270c0dcbd58fd5bafb22b61c6410
parent  e322bd568508eda227d5a56cb9a500a187a424e1
...
2
3
4
 
5
 
 
 
 
 
6
7
8
...
131
132
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
...
2
3
4
5
6
7
8
9
10
11
12
13
14
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
0
@@ -2,7 +2,13 @@
0
 
0
 use strict;
0
 use warnings;
0
+use Getopt::Long;
0
 
0
+my $help;
0
+my $ok = GetOptions("help|?" => \$help);
0
+
0
+usage() if !$ok || $help;
0
+
0
 require_module('DateTime');
0
 
0
 # Format classes to use for display
0
@@ -131,5 +137,37 @@
0
   
0
   $module->import(@_);
0
   return 1;
0
+}
0
+
0
+#######
0
+# Usage
0
+
0
+sub usage {
0
+ print STDERR <<USAGE;
0
+Usage: x-datetime-converter [--help] [-?]
0
+
0
+Reads datetime strings via stdin, and uses several methods to parse it.
0
+If the parse is sucessful, we print the parsed date in several formats.
0
+
0
+The list of formats supported is based on a list of DateTime::Format::*
0
+modules available.
0
+
0
+The following modules are used, if installed:
0
+
0
+USAGE
0
+
0
+ foreach my $mod (@formats) {
0
+ print STDERR " * DateTime::Format::$mod\n";
0
+ }
0
+
0
+ print STDERR <<USAGE;
0
+
0
+Make sure the modules are installed with:
0
+
0
+ cpan MODULE_NAME [MODULE_NAME]...
0
+
0
+USAGE
0
+
0
+ exit(1);
0
 }

Comments

    No one has commented yet.