rem ' BBjThinClient::getClientTimeZone
use java.util.Arrays
use java.util.ArrayList
use java.util.Locale
use java.util.TimeZone
precision 4
sysgui = unt
open (sysgui)"X0"
bbjapi! = bbjapi()
sysgui! = bbjapi!.getSysGui()
sysgui!.setScale(1.5,1.5)
title$ = "BBjThinClient::getClientTimeZone"
window! = sysgui!.addWindow(25,25,730,400,title$,$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
listbox! = window!.addListBox(101,10,10,350,380,$$,$$)
listbox!.setCallback(listbox!.ON_LIST_CLICK,"listclick")
window!.addGroupBox(200,370,10,350,160,"Server",$$)
serverTimeZone! = window!.addStaticText(201,380,35,330,25,"",$$)
window!.addStaticText(202,380,65,60,25,"DATE(0):",$8000$)
server_date! = window!.addStaticText(203,445,65,265,25,"DATE(MODE = SERVER)",$$)
server_date!.setToolTipText("date(0,mode=""server"")")
window!.addStaticText(204,380,95,60,25,"JUL(0,0,0):",$8000$)
server_jul! = window!.addStaticText(205,445,95,265,25,"JUL(MODE = SERVER)",$$)
server_jul!.setToolTipText("jul(0,0,0,mode=""server"")")
window!.addStaticText(206,380,125,60,25,"TIM:",$8000$)
server_tim! = window!.addStaticText(207,445,125,265,25,"TIM(MODE = SERVER)",$$)
server_tim!.setToolTipText("tim(mode=""server"")")
window!.addGroupBox(300,370,180,350,160,"Client",$$)
clientTimeZone! = window!.addStaticText(301,380,205,330,25,"",$$)
window!.addStaticText(302,380,235,60,25,"DATE(0):",$8000$)
client_date! = window!.addStaticText(303,445,235,265,25,"DATE(MODE = CLIENT)",$$)
client_date!.setToolTipText("date(0,mode=""client"")")
window!.addStaticText(304,380,265,60,25,"JUL(0,0,0):",$8000$)
client_jul! = window!.addStaticText(305,445,265,265,25,"JUL(MODE = CLIENT)",$$)
client_jul!.setToolTipText("jul(0,0,0,mode=""client"")")
window!.addStaticText(306,380,295,60,25,"TIM:",$8000$)
client_tim! = window!.addStaticText(307,445,295,265,25,"TIM(MODE = CLIENT)",$$)
client_tim!.setToolTipText("tim(mode=""client"")")
update! = window!.addButton(1,370,350,100,25,"Update")
update!.setCallback(update!.ON_BUTTON_PUSH,"update")
reset! = window!.addButton(2,480,350,100,25,"Reset")
reset!.setCallback(reset!.ON_BUTTON_PUSH,"reset")
gosub init
gosub update
process_events
eoj:
release
listclick:
event! = sysgui!.getLastEvent()
index = event!.getSelectedIndex()
if index<0 then client! = server! else client! = timezones!.get(index)
bbjapi().getThinClient().setClientTimeZone(client!)
gosub update
return
select:
print sysgui!.getLastEvent()
return
reset:
bbjapi().getThinClient().setClientTimeZone(null())
client! = bbjapi().getThinClient().getClientTimeZone()
for i = 0 to TimeZoneIDs!.size()-1
TimeZoneID$ = TimeZoneIDs!.get(i)
timezone! = TimeZone.getTimeZone(TimeZoneID$)
if client!.getID().equals(TimeZoneID$) then listbox!.selectIndex(i); break
if timezone!.hasSameRules(client!) then listbox!.selectIndex(i); break
next i
gosub update
return
update:
timezone! = server!
localName! = timezone!.getDisplayName(locale!)
defaultName! = timezone!.getDisplayName()
unicode! = timezone!.getID().concat(" - ").concat(localName!)
serverTimeZone!.setText(unicode!)
mask$ = "%Yl-%Mz-%Dz %Hz:%mz:%sz"
server_date!.setText(date(0:mask$,mode="server"))
jul = jul(0,0,0,mode="server")
date$ = date(jul:"%Yl-%Mz-%Dz",mode="server")
server_jul!.setText(date$+" = "+str(jul))
t = tim(mode="server")
h = int(t)
x = fpt(t)*60
m = int(x)
x = fpt(x)*60
s = int(x)
x = fpt(x)*1000
ms = int(x)
t$ = str(h:"00")+":"+str(m:"00")+":"+str(s:"00")+"."+str(ms:"000")
server_tim!.setText(t$+" = "+str(t))
timezone! = client!
localName! = timezone!.getDisplayName(locale!)
defaultName! = timezone!.getDisplayName()
unicode! = timezone!.getID().concat(" - ").concat(localName!)
clientTimeZone!.setText(unicode!)
mask$ = "%Yl-%Mz-%Dz %Hz:%mz:%sz"
client_date!.setText(date(0:mask$,mode="client"))
jul = jul(0,0,0,mode="client")
date$ = date(jul:"%Yl-%Mz-%Dz",mode="client")
client_jul!.setText(date$+" = "+str(jul))
t = tim(mode="client")
h = int(t)
x = fpt(t)*60
m = int(x)
x = fpt(x)*60
s = int(x)
x = fpt(x)*1000
ms = int(x)
t$ = str(h:"00")+":"+str(m:"00")+":"+str(s:"00")+"."+str(ms:"000")
client_tim!.setText(t$+" = "+str(t))
return
init:
client! = bbjapi().getThinClient().getClientTimeZone()
server! = bbjapi().getInterpreterServer().getServerTimeZone()
locale$ = bbjapi().getThinClient().getClientLocale()
locale$ = stbl("!LOCALE")
locale! = fnLocale!(locale$)
def fnLocale!(temp!)
temp! = Arrays.asList(temp!.split("_",3))
switch temp!.size()
case 3; tempLocale! = new Locale(temp!.get(0),temp!.get(1),temp!.get(2)); break
case 2; tempLocale! = new Locale(temp!.get(0),temp!.get(1)); break
case 1; tempLocale! = new Locale(temp!.get(0)); break
case default; tempLocale! = Locale.getDefault(); break
swend
return tempLocale!
fnend
default = 0
vector! = bbjapi().makeVector()
array! = TimeZone.getAvailableIDs()
Arrays.sort(array!)
TimeZoneIDs! = Arrays.asList(array!)
timezones! = new ArrayList()
localNameList! = new ArrayList()
defaultNameList! = new ArrayList()
for i = 0 to TimeZoneIDs!.size()-1
TimeZoneID$ = TimeZoneIDs!.get(i)
timezone! = TimeZone.getTimeZone(TimeZoneID$)
if !default and client!.getID().equals(TimeZoneID$) then default = i
if !default and timezone!.hasSameRules(client!) then default = i
timezones!.add(timezone!)
localName! = timezone!.getDisplayName(locale!)
defaultName! = timezone!.getDisplayName()
unicode! = timezone!.getID().concat(" - ").concat(localName!)
vector!.add(unicode!)
localNameList!.add(localName!)
defaultNameList!.add(defaultName!)
next i
listbox!.insertItems(-1,vector!)
listbox!.selectIndex(default)
return
|