# Copyright (c) 2003, 2004, 2010, 2011 Jean Forget. All rights reserved.
#
# Bistandard clock : Gregorian with 24x60x60 time,
#                    French Revolionary with 10x100x100 time.
#

use strict;
use warnings;
use DateTime::Calendar::FrenchRevolutionary;
use Tk;
use Tk::Font;
my $greg;
my $sexagesimal;
my $revolutionary;
my $decimal;
my $p = MainWindow->new();
$p->title('Clock');

my $height =  1;
my $width  = 15;
my $font   = '-*-helvetica-bold-r-*-*-*-120-*-*-*-*-*-*';

my $l1 = $p->Label(-textvariable => \$greg, -width => $width, -height => $height);
$l1->configure(-font => $font);
$l1->pack;
my $l2 = $p->Label(-textvariable => \$sexagesimal, -width => $width, -height => $height);
$l2->configure(-font => $font);
$l2->pack;
my $l3 = $p->Label(-textvariable => \$revolutionary, -width => $width, -height => $height);
$l3->configure(-font => $font);
$l3->pack;
my $l4 = $p->Label(-textvariable => \$decimal, -width => $width, -height => $height);
$l4->configure(-font => $font);
$l4->pack;
$l4->repeat(864, \&majlabel); # every decimal second

$p->Button(-text => "End", -command => sub { exit })->pack;
MainLoop;

sub majlabel {
  my $dg = DateTime::->now;
  my $dr = DateTime::Calendar::FrenchRevolutionary->from_object(object => $dg);
  $greg          = $dg->strftime("%a %d %b %Y");
  $sexagesimal   = $dg->strftime("%H:%M:%S");
  $revolutionary = $dr->strftime("%a %d %b %Y");
  $decimal       = $dr->strftime("%H:%M:%S");
}
