On Mon, 27 Aug 2001, Mayuresh A Kathe wrote:
Just incase people don't know, Philip has a neat date system designed, very much like the Stardate system aboard the Enterprise
Ok, now I remember. Didn't write anything for it (though it would be a trivial solution, given the detail). I figured it would be a voice based system, i.e., you would speak it out into your tape recorder. Didn't think that a program was required.
Anyway, here's the perl source to do it:
#!/usr/bin/perl -w
use strict; use integer; # only integer arithmetic here my $pm; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime; $year-=100; # year is index from 1900. Change to 2000 my $woy=$yday/7; # week of year is year day div 7 $min=$min*5/3; # Scale minutes to 100 $sec=$sec*5/3; # Scale seconds to 100 my @hourcodes = (8, 4, 2, 1, 0); ($hour,$pm)=($hour>=12?(23-$hour,"0-"):($hour,"")); my $hourcode=0; my $i=0; while($hour>0) { if($hour>=$hourcodes[$i]) { $hour-=$hourcodes[$i]; $hourcode+=$#hourcodes-$i; } $i++; } print sprintf("Stardate: %d%2d%1d.%s%d%2d\n", $year, $woy, $wday, $pm, $hourcode, $min);
Philip