This is a little utility I use to compress the time for small project versions. I usually just use the first 3 characters for an archive name like 'pimp-1LN.tgz' for my Perl MP3 player project or something (which is almost done). `pt` takes it's own (un-parametered) output format as a parameter to be decoded.

Obviously `pt` won't be unique beyond 5 years but it will be compact which is more important for now && archiving big blocks every 5 years isn't so bad if it means daily versioning convenience (AFAIC). I thought maybe someone might like to use `pt` since I do (I've been doing it in my head for months for months {!days though (hehe)}). Please werd your "Y2K"-lecture carefully if you must reprimand me for my blatant ignorance of future-proofness. TTFN =).
#!/usr/bin/perl -w # pt (PipTime) is a simple tool created to en/decode the following fie +lds: # 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 AllNigh +ter =). # 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 && sh +all 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...

-PipTigger
p.s. JAPM.

In reply to PipTime by PipTigger

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.