use warnings;
use strict;
use Tk;
use DateTime;
use Time::HiRes qw(time);
my $time;
# Specify the day you're counting down to here
my $then = DateTime->new(year => 2003, month => 12, day => 30, hour =>
+ 17,
minute => 30, second => 0, time_zone => 'loca
+l');
my $mw = MainWindow->new;
$mw->Label(-textvariable => \$time, -font => "{arial} 12 bold")->pack;
$mw->repeat(4, \&update);
update();
$mw->overrideredirect(1);
$mw->geometry("+0+0");
MainLoop;
sub update {
my $now = DateTime->from_epoch(epoch => time, time_zone => 'local'
+);
my $dur = ($then - $now);
$time = $dur->days . " days ";
$time .= $dur->hours . ":";
$time .= sprintf("%.2d", $dur->minutes) . ":";
$time .= sprintf("%.2d", $dur->seconds) . ":";
$time .= sprintf("%.3d", int($dur->nanoseconds / 1000000));
}
In reply to Countdown
by batkins
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|