bon c'est assez complique, je l'ai extrait d'un programme donc ce n'est pas tres clair
Code : Tout sélectionner
Enumeration
#window_0 ; Window
#jn:#mn:#yn:#jj:#mj:#yj ; Combo
#Text_DOW
EndEnumeration
Global NewList moij.s()
Global Dim tmoi.s(12,2)
Global Dim twik.s(7,2)
Global Dim tadr.s(2,2)
Global ymin=1900,yscl=200
Define.l:Global k,jn,mn,yn,jj,mj,yj
Define.d:Global jd
IncludeFile "proced.pb"
texte():liste():OpenWindow_Window_0()
filldate()
jh=procdates(0)
HideWindow(#window_0,0)
jh=procdates(1)
SetGadgetText(#Text_DOW,week(jh-1))
Repeat
yhe=WaitWindowEvent()
gad=EventGadget()
wev=WindowEvent()
Select gad
Case #jn,#mn,#yn:jh=procdates(1)
Case #jj,#mj,#yj:jh=procdates(2)
EndSelect
adar(jh)
Select yhe
Case #PB_Event_CloseWindow:qit=1
EndSelect
Until qit=1
End
Code : Tout sélectionner
Procedure.d FPart(x.d):If x=>0:ProcedureReturn x-Int(x):EndIf
If x<0:ProcedureReturn x+Int(x):EndIf:EndProcedure
Procedure.d Rnd(x.d,y):ProcedureReturn Int(x*Pow(10,y))/Pow(10,y):EndProcedure
Procedure.d Mod(x.d,y):a.d=rnd(x-Int(x/y)*y,5)
If a<0:a+y:EndIf:ProcedureReturn a:EndProcedure
Procedure.s Str0(x):a.s="":If x<10:a="0":EndIf
ProcedureReturn a+Str(x):EndProcedure
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 352, 167, 600, 50, "", #PB_Window_TitleBar|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_SystemMenu|#PB_Window_Invisible)
If CreateGadgetList(WindowID(#Window_0))
ComboBoxGadget(#jn, 10, 10, 50, 30)
ComboBoxGadget(#mn, 70, 10, 100, 30)
ComboBoxGadget(#yn, 180, 10, 80, 30)
ComboBoxGadget(#jj, 545, 10, 50, 30)
ComboBoxGadget(#mj, 440, 10, 95, 30)
ComboBoxGadget(#yj, 350, 10, 80, 30)
TextGadget(#Text_DOW, 270, 10, 70, 20, "")
EndIf
EndIf
EndProcedure
Procedure texte()
tmoi(1,2)="January"
tmoi(2,2)="February"
tmoi(3,2)="March"
tmoi(4,2)="April"
tmoi(5,2)="May"
tmoi(6,2)="June"
tmoi(7,2)="July"
tmoi(8,2)="August"
tmoi(9,2)="September"
tmoi(10,2)="October"
tmoi(11,2)="November"
tmoi(12,2)="December"
tadr(1,2)="Adar"
tadr(2,2)="Adar 2"
twik(1,2)="Sunday"
twik(2,2)="Monday"
twik(3,2)="Tuesday"
twik(4,2)="Wednesday"
twik(5,2)="Thursday"
twik(6,2)="Friday"
twik(7,2)="Saturday"
EndProcedure
Procedure liste()
AddElement(moij()):moij()="Tishri"
AddElement(moij()):moij()="Heshvan"
AddElement(moij()):moij()="Kislev"
AddElement(moij()):moij()="Tevet"
AddElement(moij()):moij()="Shevat"
AddElement(moij()):moij()="Adar"
AddElement(moij()):moij()="Nissan"
AddElement(moij()):moij()="Iyar"
AddElement(moij()):moij()="Sivan"
AddElement(moij()):moij()="Tamouz"
AddElement(moij()):moij()="Av"
AddElement(moij()):moij()="Eloul"
EndProcedure
;-Dates
Procedure.s week(jd)
ProcedureReturn twik(Int(mod(jd+1.5,7)+1),2)
EndProcedure
Procedure jhtn(jh)
If jh>1951163
f=Int((jh-1519219.25)/36524.25)
a=JH+1+F-Int(f/4)+347997
EndIf
If jh<1951164
a=jh+347997
EndIf
b=a+1524
c=Int((B-122.1)/365.25)
d=Int(365.25*C)
e=Int((b-d)/30.6001)
If e>13
jn=b-d-Int(30.6001*E)
mn=e-13
yn=c-4715
EndIf
If e<14
jn=b-d-Int(30.6001*E)
mn=e-1
yn=c-4716
EndIf
EndProcedure
Procedure tnjh()
x=0
g=0
b.d=0
f.d=0
mmn=mn
ynn=yn
If mmn<3
ynn-1
mmn+12
EndIf
If ynn+mmn/100+jn/10000>1582.1004
a.d=Int(ynn/100)
b=2-a+Int(a/4)
EndIf
If ynn<0
f=0.75
EndIf
jh.d=Int(365.25*ynn-f)+Int(30.6001*(mmn+1))+jn+1372998+b
ProcedureReturn jh
EndProcedure
Procedure jhti(jh)
a=Int((25920*jh)/765433)
yj=Int((19*a+252)/235)
c=mod(12*yj+17,19)
a=Int((1+235*(yj-1))/19)
b=(765433*a+63924)/25920
d.d=b-Int(b/7)*7
If Int(d)=1 Or Int(d)=4 Or Int(d)=6
x=1
EndIf
If Int(d)=3 And d>=7847/2160 And c<12
x=2
EndIf
If Int(d)=2 And d>=75109/25920 And c>4 And c<12
x=1
EndIf
e.d=Int((1+235*yj)/19)
f.d=(765433*e+63924)/25920
p.d=f-Int(f/7)*7
If Int(p)=1 Or Int(p)=4 Or Int(p)=6
g=1
EndIf
If Int(p)=3 And p>=7847/2160 And c>6
g=2
EndIf
If Int(p)=2 And p>=75109/25920 And c>11
g=1
EndIf
w=Int(f)+g-Int(b)-x
h=Int(b)+x-2
v=jh-h
If v<1
jj=29+v
mj=12
yj-1
c=mod(12*yj+17,19)
EndIf
If v<1 And c>11
mj=13
EndIf
If v>0
If w=383 Or w=353
z=v+Int((v+291)/380)
EndIf
If w=384 Or w=354
z=v
EndIf
If w=385 Or w=355
z=v-Int((v+319)/380)
EndIf
If w<380
mj=Int((z+28.5)/29.5)
jj=z-Int(29.5*mj)+29
EndIf
If w>380
mj=Int((z+28.5-0.5*Int((z+232)/380))/29.5)
jj=z-Int(29.5*mj)+29-Int(fpart((0.5*mj)*Int((mj+5)/12))+0.5)
EndIf
If v=60 And w=355
mj=2
jj=30
EndIf
If v=60 And w=385
mj=2
jj=30
EndIf
EndIf
EndProcedure
Procedure tijh()
x=0
g=0
c.l=mod(12*yj+17,19)
a=Int((1+235*(yj-1))/19)
b=(765433*a+63924)/25920
d=b-Int(b/7)*7
If Int(d)=1 Or Int(d)=4 Or Int(d)=6
x=1
ElseIf Int(d)=3 And d>=7847/2160 And c<12
x=2
ElseIf Int(d)=2 And d>=75109/25920 And c>4 And c<12
x=1
EndIf
e.d=Int((1+235*yj)/19)
f.d=(765433*e+63924)/25920
p.d=f-Int(f/7)*7
If Int(p)=1 Or Int(p)=4 Or Int(p)=6
g=1
ElseIf Int(p)=3 And p>=7847/2160 And c>6
g=2
ElseIf Int(p)=2 And p>=75109/25920 And c>11
g=1
EndIf
w=Int(f)+g-Int(b)-x
h=Int(b)+x-2
Select w
Case 353,383
z=Int(29.5*mj)-29+jj-Int((mj+8)/12)
Case 354,384
z=Int(29.5*mj)-29+jj
Case 355,385
z=Int(29.5*mj)-29+jj+Int((mj+9)/12)
EndSelect
If w<380
v=z
ElseIf w>380
v=z+Int(fpart(0.5*mj*Int((mj+5)/12))+0.5)
EndIf
jh=h+v
ProcedureReturn jh
EndProcedure
Procedure FillDate()
For k=1 To 12
AddGadgetItem(#mn,-1,tmoi(k,2))
Next
For k=0 To 11
SelectElement(moij(), k)
AddGadgetItem(#mj,-1,moij())
Next
For k=1 To 31
AddGadgetItem(#jn,-1,Str(k))
Next
For k=ymin To ymin+yscl
AddGadgetItem(#yn,-1,Str(k))
Next
For k=ymin+3760 To ymin+3760+yscl
AddGadgetItem(#yj,-1,Str(k))
Next
For k=1 To 30
AddGadgetItem(#jj,-1,Str(k))
Next
SetGadgetState(#jn,jn)
SetGadgetState(#mn,mn)
SetGadgetState(#yn,yn)
EndProcedure
Procedure procdates(flag)
If flag=0
jn=Val(FormatDate("%dd",Date()))
mn=Val(FormatDate("%mm",Date()))
yn=Val(FormatDate("%yyyy",Date()))
jh=tnjh():jhti(jh)
SetGadgetState(#jn,jn-1)
SetGadgetState(#mn,mn-1)
SetGadgetState(#yn,yn-ymin)
SetGadgetState(#jj,jj-1)
SetGadgetState(#mj,mj-1)
SetGadgetState(#yj,yj-ymin-3760)
ElseIf flag=1
jn=GetGadgetState(#jn)+1
mn=GetGadgetState(#mn)+1
yn=GetGadgetState(#yn)+ymin
jh=tnjh():jhti(jh)
SetGadgetState(#jj,jj-1)
SetGadgetState(#mj,mj-1)
SetGadgetState(#yj,yj-ymin-3760)
ElseIf flag=2
jj=GetGadgetState(#jj)+1
mj=GetGadgetState(#mj)+1
yj=GetGadgetState(#yj)+ymin+3760
jh=tijh():jhtn(jh)
SetGadgetState(#jn,jn-1)
SetGadgetState(#mn,mn-1)
SetGadgetState(#yn,yn-ymin)
EndIf
SetGadgetText(#Text_DOW,week(jd))
ProcedureReturn jh
EndProcedure
Procedure adar(jh)
c.l=Mod(12*yj+17,19)
If c>11 And GetGadgetItemText(#mj,12)=""
AddGadgetItem(#mj,6,tadr(2,2))
EndIf
If c<12 And GetGadgetItemText(#mj,12)<>"" And GetGadgetItemText(#mj,6)=tadr(2,2)
RemoveGadgetItem(#mj,6)
EndIf
jd=jh+347996.5
If GetGadgetText(#mj)=""
SetGadgetText(#mj,tadr(1,2))
EndIf
EndProcedure