ONO::FW::Edu::Apps::Modules::WorldClock

package ONO::FW::Edu::Apps::Modules::WorldClock;
################################################################################
# COPYRIGHT / LICENSE #
################################################################################
#
# This file is part of the ONO Software Project.
#
# Copyright (C) 2022-2026 Jos Kirps and The Joopita Project [ASBL]
# Copyright (C) 2011-2022 Jos Kirps and Joopita Research ASBL
# Copyright (C) 2006-2011 Jos Kirps and The Joopita Project
# Copyright (C) 2001-2006 Jos Kirps and The WobbleWolf Project
#
# This file, as well as many other parts of the ONO Software Project or
# related elements, are FREE SOFTWARE available under the ARTISTIC LICENSE 2.0.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For the full license, see /ono/osr/license/LICENSE.txt, or write to
# jos_AT_kirps_DOT_com or contact_AT_joopita_DOT_com.
#
################################################################################
# END OF COPYRIGHT / LICENSE, HERE COMES THE CODE ... #
################################################################################

#: This module is a front end application module wrapper that has been
#: created for the Morzino Project (morzino.com) and that has been released
#: as Open Source software.
#:
#: Note that this is NOT a self-contained application, it is only a wrapper
#: that makes heavy use of the ONO Perl Framework application engine.

use strict;

use Encode;

use ONO::Render;

use ONO::ToolBox::Auth;
use ONO::Lib::Lang::LangKitEdu;

use ONO::Lib::DateTime::ToolBox;
use ONO::Lib::Web::Domain;

use ONO::FW::Apps::Core;
use ONO::FW::Apps::Core::Graphics;

use ONO::FW::Edu::Apps::ToolBox;
use ONO::FW::User::Init;
use ONO::Lib::DateTime::Clock;
use ONO::IO;

use ONO::FW::Edu::Apps::Variation;

sub learn {

my (
$self,
$option,
$vars_ref,
$HTTP,
$BASE,
) = @_;

################################################################
# INIT - BEGIN
################################################################

my (
$db,
$community,
$action_url,
$form,
$format,
$canvas,
$pdfkey,
$sec,$min,$hour,
$mday,$mon,$year,
$wday,$yday,$timestamp,
$lang,
$BLK_ref,
$vars_ref,
) = ONO::FW::Apps::Core->init($vars_ref);

my %vars = %$vars_ref;
my %BLK = %$BLK_ref;

ONO::FW::Apps::Core->now("","worldclock",$vars{'app_lang'});

my $action_url = qq~$ENV{'SCRIPT_NAME'}?app_lang=$vars{'app_lang'}&~;

###################################################################
# CLOCK
###################################################################

my @cities = (
"Los Angeles, Vancouver",
"Denver",
"Dallas, Mexico City",
"New York, Washington D.C., Toronto",
"Santiago",
"Rio de Janero, Buenos Aires",
"",
"",
"London, Reykjavík, Lisbon",
"Paris Berlin, Madrid Rome",
"Helsinki, Kiev, Cape Town",
"Moscow, Saint Petersburg, Istanbul",
"",
"Yekaterinburg",
"",
"",
"Shanghai, Bejing, Manila Perth",
"Tokyo, Seoul",
"Sydney, Melbourne",
);

if ($ENV{'SERVER_NAME'} =~ /oli/ || $community eq "school") {
$cities[9] = "Luxembourg, Paris Berlin, Madrid Rome",
}

my $WEB = qq~<div class="inline w100">~;

foreach my $opt (-8,-7,-6,-5,-4,-3,0,1,2,3,5,8,9,10) {

$cities[$opt+8] =~ s~,~<br>~g;

my $current = $hour+$opt-1;
my $color = "fff:d34:812:bbb";
if ($current > 18 || $current < 7) {
$color = "eee:b12:600:aaa";
}
if ($current > 19 || $current < 6) {
$color = "ddd:900:400:999";
}
if ($current > 20 || $current < 5) {
$color = "ccc:700:200:888";
}
if ($current > 21 || $current < 4) {
$color = "bbb:500:000:777";
}
if ($current > 22 || $current < 3) {
$color = "aaa:300:000:666";
}
if ($current > 23 || $current < 2) {
$color = "999:100:000:555";
}
if ($current > 24 || $current < 1) {
$color = "888:000:000:444";
}

$WEB .= qq~ <div class="block128 fl center lh125" style="width:129px;height:200px">~;
$WEB .= ONO::Lib::DateTime::Clock->canvas_clock(128,$current,"","","c","#$color");
$WEB .= qq~ $cities[$opt+8]</div>~;

}

$WEB .= qq~</div>~;

$WEB .= ONO::IO->refresh("$ENV{'SCRIPT_NAME'}?app_lang=$vars{'app_lang'}",1000);

return $WEB;

}

###################################################################
#### THAT'S IT :-D
###################################################################

1;

__END__