in reply to hex clock

Why are you using the external date command? One of the time functions (localtime etc.) is probably a better bet.

If the clock is a hexidecimal clock then surely there should be F hours in a day made up of FF minutes made up of FF seconds. When you started the script you would have to convert the current time into hex time (and account for shorter seconds). You also need to check out the terminal modules so that the time can update in the same place on the console screen.

Replies are listed 'Best First'.
Re^2: hex clock
by ysth (Canon) on Apr 14, 2005 at 22:29 UTC
    I hope you mean that hours would range from 0-F, and minutes and seconds from 00-FF. That makes for about 12 hex seconds per real second, though.
      I wasn't suggesting that 'Hex time' was a good idea per se it's just that representing the passage of time in a different measurement was more interesting than sprintf-ing the plain old hours minutes and seconds.

      What about 16-bit time as a concept? Subdividing a day into FFFF bits isn't too far off the number of conventional seconds in a day.

        I'd completely forgotten to do this. How about:
        #!/usr/bin/perl use strict; use Time::HiRes qw( usleep ); my $hex_sec_of_day=0; my $HEX_SEC = 0.7585069444444; my $HEX_MS_IN_SEC = $HEX_SEC*1000000; sub calc_curr_time_as_hex() { my ($s,$m,$h,@rest)=localtime(time()); # my $s=58;my $m=59;my$h=23; # test data $hex_sec_of_day = (($s+($m*60)+($h*3600))*$HEX_SEC); } calc_curr_time_as_hex(); $|=1; while(1) { printf ("\r0x%04x ", $hex_sec_of_day); $hex_sec_of_day++; # day flips from 0xFFFE to 0x0000, move thi +s line # below next line to have midnight as 0xFFF +F $hex_sec_of_day=0x0000 if($hex_sec_of_day>0xffff); usleep($HEX_MS_IN_SEC); }
Re^2: hex clock
by ciderpunx (Vicar) on Apr 15, 2005 at 14:43 UTC
    Yep, good point, localtime would be better.
    As for coming up with a hex representation of time, maybe I'll try that next...
    Cheers folks
    Charlie