#!/usr/bin/perl -w # pt (PipTime) is a simple tool created to en/decode the following fields: # Year*12+Month, Day, Hour, Minute, Second into/from a terse 5-char string. # The pt method will be unique until Feb. 2006. Created 1L7Mu AllNighter =). # There's no !ERROR! checking so I might add some should it ever seem useful. # I like to use brief encoded dates to version things so this lets me quickly # choose a duration granularity as my next unique version descriptor. TTFN. # All source code should be free! Code I have authority over is && shall be! # -Pip@BinQ.org use strict; my %mapz = (); # This guy will hold @valz as keys && indices as values for lookups my @valz = ( 0..9, 'A'..'Z', 'a'..'z' ); # 0-61 dayz->V(31) minz->x(60) my @dayo = ( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sha" ); my @mnth = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); my $tout = shift; my @time = localtime(); my $year = 1; if (defined($tout)) { for(my $i=0; $i<@valz; $i++) { $mapz{$valz[$i]} = $i; } @time = split //, $tout; splice(@time,5,127); # chop extras off! for(my $i=0; $i<5; $i++) { unless(defined($time[$i])) { $time[$i] = 0; } } while ($mapz{$time[0]} > 12) { $year++; $time[0] = $valz[$mapz{$time[0]}-12]; } unshift(@time, $year+2000); print "$mnth[$mapz{$time[1]}-1] $mapz{$time[2]}, $time[0] "; if ($mapz{$time[3]} < 10) { print "0"; } print "$mapz{$time[3]}:"; if ($mapz{$time[4]} < 10) { print "0"; } print "$mapz{$time[4]}:"; if ($mapz{$time[5]} < 10) { print "0"; } print "$mapz{$time[5]}"; } else { $time[5] -= 101; $time[4] = $valz[(++$time[4]+(12*$time[5]))]; $time[3] = $valz[$time[3]]; $time[2] = $valz[$time[2]]; $time[1] = $valz[$time[1]]; $time[0] = $valz[$time[0]]; splice(@time,5,4); @time = reverse(@time); print @time; } # print "\n"; # hmmm...