Browse files

'home' migration: Move 'stamp' function into a script instead.

  • Loading branch information...
1 parent f14c44c commit c43817497fb98494d37e1438a32d86ba3f739d3f @norm committed May 8, 2010
Showing with 19 additions and 12 deletions.
  1. +19 −0 bin/stamp
  2. +0 −12 etc/bash/rc/perl
View
19 bin/stamp
@@ -0,0 +1,19 @@
+#!/usr/bin/env perl
+# github:norm:homedir:bin/stamp
+# -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil; -*-
+#
+# Provide unix-epoch style timestamp conversion (in UTC).
+
+use 5.10.0;
+use Date::Manip;
+
+my $time = shift // 'now';
+
+# convert numeric timestamps to human-readable dates
+if ( $time =~ m{^\d+$} ) {
+ say scalar( gmtime $time );
+}
+# convert anything else to a numeric timestamp
+else {
+ say UnixDate( $time, '%s' );
+}
View
12 etc/bash/rc/perl
@@ -8,16 +8,4 @@ export PERL5LIB="${HOME}/lib/perl"
alias pm='perl Makefile.PL ; make ; make test'
-# convert to/from timestamps
-function stamp {
- perl -MDate::Manip -e "
- \$time = q(${*});
- if ( \$time =~ m{^\d+$} ) {
- print scalar( gmtime \$time ) . qq(\n);
- }
- else {
- print UnixDate( \$time, qq(%s\n) );
- }
- "
-}

0 comments on commit c438174

Please sign in to comment.