Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Clock that goes backwards

by shmem (Chancellor)
on May 18, 2007 at 18:41 UTC ( [id://616252]=CUFP: print w/replies, xml ) Need Help??

Well, this is a "Silly use for Perl", but there is no such section, so I post it here.
#!/usr/bin/perl use strict; use Tk; BEGIN {*Tk::Clock::time = sub { time * -1 } } use Tk::Clock; my $wm = MainWindow->new; my $ck = $wm->Clock->pack(); $ck->config(dateFormat => "dd-mm-yyy"); MainLoop;

This clock displays the time since the Epoch - but into the past.

To have it display the time going back from the moment the clock started, use

BEGIN { my $time = time; *Tk::Clock::time = sub { 2 * $time - time }; }

before loading Tk::Clock.

update: while being silly, it also shows an interesting fact about UNIX time, and how to override core functions for modules to-be-loaded... eeevil... ;-)


_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re: Clock that goes backwards
by grinder (Bishop) on May 19, 2007 at 06:10 UTC

    I have a friend who has a clock. The long hand does a counter-clockwise revolution once every 24 hours. The short hand does a clockwise revolution every hour. I usually need to look at another clock in order to be able to decode it.

    • another intruder with the mooring in the heart of the Perl

Re: Clock that goes backwards
by graff (Chancellor) on May 19, 2007 at 04:31 UTC
    When I was growing up, we had a wall clock with a great gimmick: the arrangement of the numbers on the face and the movement of the hands were both counter-clockwise. Telling time on that clock was sort of like speaking a foreign language.

    Adding numbers to Tk::Clock's "analog" display, and inverting the y X coordinates, would be a cute trick...

Re: Clock that goes backwards
by ady (Deacon) on May 24, 2007 at 06:02 UTC
    Last time i mounted a wall clock (at home), i did it upside down. . . "With time" the family learned to read it, and when we had the walls painted after a year and I mounted the clock the "normal way", no one could decode it right away for several weeks.

    Reminds me of the psychological experiment with the prism googles, . . . and the ethological observation of the rat that jumped the bar in the labyrint, long time after the bar was removed.

    But those are other stories, and it's bedtime now :)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://616252]
Approved by kyle
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-05-25 22:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found