Doh!!! Story of my life .... a day late and a dollar short. I knew something wasn't right, it's that add 1 to $mon, but not to $mday gotch!! Arghh. It was last night. Anyways, this does show the difference in Perl/Tk and Perl/Gtk2 programming.

This is just a dumb and easy script, to help you easily partake in the great 1111111111 celebration this evening ( at around 8:58:30 Eastern Daylight Savings Time (by my calculations....I may be wrong :=0)). I wouldn't have thought of it, except for 1111111111 , followed by a post on the Gtk2-Perl maillist, about a Gtk2 countdown timer. So I figured Tk, may as well throw it's code into the celebration. I was going to add a warning beeper, 15 seconds before the fireworks, but I figure that would be too annoying. The Gtk2 code is also shown below for comparison.

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; $mw->fontCreate('big', -family=>'Arial', -weight=>'bold', -size=>int(-24*24/14)); my $ctime = time; my $lab = $mw->Label( -background => 'lightgreen', -font =>'big', -textvariable=> \$ctime)->pack(); $mw->repeat(500, sub{ $ctime = time }); MainLoop; __END__ #Gtk2 version by McLean of the gtk2-perl maillist ###################################################### #!/usr/bin/perl use strict; use Gtk2 -init; use Glib qw(TRUE FALSE); my $window = Gtk2::Window->new; $window->signal_connect(delete_event => sub { Gtk2->main_quit; }); my $label = Gtk2::Label->new('' . time()); my $font = Gtk2::Pango::FontDescription->from_string("Sans Bold 48"); $label->modify_font($font); Glib::Timeout->add(250, sub { $label->set_text('' . time()); TRUE; }); $window->add($label); $window->show_all; Gtk2->main; __END__

Replies are listed 'Best First'.
Re: 1111111111-countdown-watcher (too late)
by tye (Sage) on Mar 18, 2005 at 17:41 UTC

    Um. That passed... yesterday.

    $ perl -e "print time()" 1111167701

    - tye        

      Yeah, I feel dumb. I was thrown off by 1111111111 where esskar said Friday. My mind went into panic when I saw the 1111157949, and thought "how can that ever go to all 1's?. Then it took me a few minutes to figure out the $mday thing. Of well, I can't blame esskar....I'm so scattered, I usually don't even know what day of the week it is. :-)

      I'm not really a human, but I play one on earth. flash japh
Re: 1111111111-countdown-watcher
by chanio (Priest) on Mar 22, 2005 at 04:18 UTC
    Thanks, I added some lines to have an extravagant clock...

    use strict; local $| = 1; use Tk; use POSIX qw(strftime setlocale LC_ALL LC_CTYPE); my ($whatsUrLocale)= 'es_AR.ISO8859-1'; my ($dateFormat) = "%A, %d %b %H:%M:%S %Y"; my ($clockTitle) = 'TEMPUS FUGIT'; my ($loc) = POSIX::setlocale( &POSIX::LC_ALL, $whatsUrLocale ); ## Just in case... $ENV{LANG} = $whatsUrLocale; my $mw = new MainWindow; $mw->title($clockTitle); $mw->fontCreate('mini', -family=>'Arial', # -weight=>'bold', -size=>int(-11*11/6)); $mw->fontCreate('big', -family=>'Arial', -weight=>'bold', -size=>int(-24*24/14)); my $ctime = ' '. time ; my $horeja= strftime $dateFormat, localtime; my $hor = $mw->Label( -background => 'lightblue', -foreground => 'darkblue', -font =>'mini', -textvariable=> \$horeja )->pack(); my $lab = $mw->Label( -background => 'lightgreen', -foreground => 'orange', -font =>'big', -textvariable=> \$ctime)->pack(); $mw->repeat(500, sub{ $ctime = ' '. time; $horeja= strftime $dateForma +t, localtime; }); MainLoop; __END__

    UPDATED: Sorry, I was meaning the DOW "%A" instead of the month "%a". Thanks zentara

    .{\('v')/}   C H E E R   U P !
     _`(___)' ___a_l_b_e_r_t_o_________
    
    Wherever I lay my KNOPPIX disk, a new FREE LINUX nation could be established.
      As a minor nitpick, I get the month repeated twice, in your

      my ($dateFormat) = "%a, %d %b %H:%M:%S %Y";

      I remove either the %a or the %b, to suit my tastes. But maybe you have a reason for doing it that way?


      I'm not really a human, but I play one on earth. flash japh