Page 1 sur 1

Calculatrice Micoute (Fuseaux horaires)

Publié : dim. 19/nov./2017 7:13
par Micoute
Bon dimanche à tous

Voici une nouvelle partie de ma calculatrice, celle-ci, comme vous l'avez deviné, affiche l'heure dans les fuseaux horaires sélectionnés, j'en ai mis un pour le fuseau local, et quatre pour comparer le décalage avec, le source étant fourni vous pouvez le modifié comme il vous plaira.

Code : Tout sélectionner

;Calculatrice Micoute (Fuseaux horaires)

;Créateur du logiciel : Michel Lye (Micoute)
;Date de création : 18 novembre 2017
;Version de PB utilisée 5.61 (x86)
;Version de Windows utilisée : Windows 10 64 bits


;Si vous souhaitez modifier les données

;Les fuseaux horaires se trouvent dans le registre de Windows 10, à l'adresse suivante :
; HKEY_LOCAL_MACHINE
;   SOFTWARE
;     Microsoft
;       Windows NT
;         CurrentVersion
;           Time Zone
;             time_zone_name

Enumeration
  #Fenetre_Fuseaux
EndEnumeration

Enumeration
  #Ctn_Fuseaux
  #Txt_Comparer
  #Txt_Fuseau_base
  #Txt_Heure_base
  #Str_Jour_base
  #Str_Heure_base
  #Cmb_FH_base
  #Cmb_Fuseau_1
  #Cmb_Fuseau_2
  #Cmb_Fuseau_3
  #Cmb_Fuseau_4
  #Str_Fuseau_1
  #Str_Fuseau_2
  #Str_Fuseau_3
  #Str_Fuseau_4
  #Timer_FH
EndEnumeration

Enumeration Police
  #Police_1
  #Police_2
EndEnumeration  

Structure sFuseau
  Decalage.s
  Lieux.s
EndStructure

Structure sDecal
  Heure.i
  Minute.i
EndStructure  

LoadFont(#Police_1, "Arial", 8, #PB_Font_HighQuality)
LoadFont(#Police_2, "Arial", 12, #PB_Font_Bold)  

Declare Lire_Donnees()
Declare Ouvrir_Fenetre_Fuseaux()

Global Evenement, Dim Fuseaux.sFuseau(119), Dim HeureFuseau.i(119), Dim MinuteFuseau.i(119), I, ID
Global.TIME_ZONE_INFORMATION lpTimeZoneInformation

JS.s="Dimanche,Lundi,Mardi,Mercredi,Jeudi,Vendredi,Samedi"
NomMois.s="janvier,février,mars,avril,mai,juin,juillet,aout,septembre,octobre,novembre,decembre"

Procedure.i DecalageHoraire()  
  Select GetTimeZoneInformation_(@lpTimeZoneInformation)
    Case 1 : ProcedureReturn #False
    Case 2 : ProcedureReturn #True
    Case 0 : ProcedureReturn -1
  EndSelect  
EndProcedure

Procedure Lire_Donnees()
  Protected.s Dec, Lieu
  Restore Debut
  For i = 0 To ArraySize(Fuseaux())
    Read.s dec
    Fuseaux(i)\Decalage = "UTC"+Dec
    Read.s Fuseaux(i)\Lieux
  Next i
EndProcedure

Procedure Ouvrir_Fenetre_Fuseaux()
  If OpenWindow(#Fenetre_Fuseaux, 450, 200, 570, 250, "Fuseaux horaires", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
    
    SetGadgetFont(#PB_Default, FontID(#Police_1))
    
    ContainerGadget(#Ctn_Fuseaux, 0, 0, 570, 250, #PB_Container_Raised)
    TextGadget(#Txt_Fuseau_base, 10, 0, 120, 30, "Fuseau horaire de base", #PB_Text_Right|#SS_CENTERIMAGE)
    ComboBoxGadget(#Cmb_FH_base, 140, 0, 415, 30)
    For i = 0 To ArraySize(Fuseaux())
      AddGadgetItem(#Cmb_FH_base, i, Fuseaux(i)\Decalage + " " + Fuseaux(i)\Lieux)
    Next i  
    
    TextGadget(#Txt_Heure_base, 10, 40, 120, 30, "Heure de base", #PB_Text_Right|#SS_CENTERIMAGE)
    StringGadget(#Str_Heure_base, 140, 40, 325, 30, "")
    StringGadget(#Str_Jour_base, 475, 40, 80, 30, "")
    
    TextGadget(#Txt_Comparer, 10, 70, 120, 30, "Comparer avec", #SS_CENTERIMAGE)
    ComboBoxGadget(#Cmb_Fuseau_1, 10, 100, 455, 30)
    StringGadget(#Str_Fuseau_1, 475, 100, 80, 30, "", #PB_String_ReadOnly)
    For i = 0 To ArraySize(Fuseaux())
      AddGadgetItem(#Cmb_Fuseau_1, i, Fuseaux(i)\Decalage + " " + Fuseaux(i)\Lieux)
    Next i
    ComboBoxGadget(#Cmb_Fuseau_2, 10, 135, 455, 30)
    StringGadget(#Str_Fuseau_2, 475, 135, 80, 30, "", #PB_String_ReadOnly)
    For i = 0 To ArraySize(Fuseaux())
      AddGadgetItem(#Cmb_Fuseau_2, i, Fuseaux(i)\Decalage + " " + Fuseaux(i)\Lieux)
    Next i
    ComboBoxGadget(#Cmb_Fuseau_3, 10, 170, 455, 30)
    StringGadget(#Str_Fuseau_3, 475, 170, 80, 30, "", #PB_String_ReadOnly)
    For i = 0 To ArraySize(Fuseaux())
      AddGadgetItem(#Cmb_Fuseau_3, i, Fuseaux(i)\Decalage + " " + Fuseaux(i)\Lieux)
    Next i
    ComboBoxGadget(#Cmb_Fuseau_4, 10, 205, 455, 30)
    StringGadget(#Str_Fuseau_4, 475, 205, 80, 30, "", #PB_String_ReadOnly)
    For i = 0 To ArraySize(Fuseaux())
      AddGadgetItem(#Cmb_Fuseau_4, i, Fuseaux(i)\Decalage + " " + Fuseaux(i)\Lieux)
    Next i
    
    CloseGadgetList()
    
    SetGadgetState(#Cmb_FH_base, 6)
    
    For i = #Str_Jour_base To #Str_Fuseau_4
      SetGadgetFont(i, FontID(#Police_2))
    Next i  
    
    AddWindowTimer(#Fenetre_Fuseaux, #Timer_FH, 1000)
  EndIf
EndProcedure

Lire_Donnees()
Ouvrir_Fenetre_Fuseaux()

Procedure Calcul_FH(Id)
  DecalageHoraire()
  HeureFuseau(ID) = (Val(Mid(GetGadgetText(Id), 4, 4))+Hour(Date()) %24) + lpTimeZoneInformation\Bias / 60
  MinuteFuseau(ID) = (Val(Mid(GetGadgetText(Id), 8, 4))+Minute(Date()) %60)
  i = MinuteFuseau(ID)
  While i >= 60
    i - 60
    HeureFuseau(ID) + 1
    MinuteFuseau(id) = i
  Wend  
  i = HeureFuseau(id)
  If i < 0
    i + 24
  EndIf
  HeureFuseau(id) = i
EndProcedure

;- Boucle
Repeat
  Evenement = WaitWindowEvent()
  Select Evenement
      
    Case #PB_Event_Timer
      Select EventTimer()
        Case #Timer_FH
          Calcul_FH(#Cmb_FH_base)
          If GetGadgetText(#Cmb_FH_base)
            SetGadgetText(#Str_Heure_base, StringField(JS, DayOfWeek(Date()) + 1, ",") + " " + Str(Day(Date())) + " " + StringField(NomMois, Month(Date()), ",") + " " + Str(Year(Date())))
            SetGadgetText(#Str_Jour_base, RSet(Str(HeureFuseau(#Cmb_FH_base)), 2, "0") + ":" + RSet(Str(MinuteFuseau(#Cmb_FH_base)), 2, "0") + ":" + RSet(Str(Second(Date())),2,"0"))
          EndIf
          If GetGadgetText(#Cmb_Fuseau_1)
            Calcul_FH(#Cmb_Fuseau_1)
            SetGadgetText(#Str_Fuseau_1, RSet(Str(HeureFuseau(#Cmb_Fuseau_1)%24), 2, "0")+":"+RSet(Str(MinuteFuseau(#Cmb_Fuseau_1)%60), 2, "0") + ":" + RSet(Str(Second(Date())), 2, "0"))
          EndIf
          If GetGadgetText(#Cmb_Fuseau_2)
            Calcul_FH(#Cmb_Fuseau_2)
            SetGadgetText(#Str_Fuseau_2, RSet(Str(HeureFuseau(#Cmb_Fuseau_2)%24), 2, "0")+":"+RSet(Str(MinuteFuseau(#Cmb_Fuseau_2)%60), 2, "0") + ":" + RSet(Str(Second(Date())), 2, "0"))
          EndIf
          If GetGadgetText(#Cmb_Fuseau_3)
            Calcul_FH(#Cmb_Fuseau_3)
            SetGadgetText(#Str_Fuseau_3, RSet(Str(HeureFuseau(#Cmb_Fuseau_3)%24), 2, "0")+":"+RSet(Str(MinuteFuseau(#Cmb_Fuseau_3)%60), 2, "0") + ":" + RSet(Str(Second(Date())), 2, "0"))
          EndIf
          If GetGadgetText(#Cmb_Fuseau_4)
            Calcul_FH(#Cmb_Fuseau_4)
            SetGadgetText(#Str_Fuseau_4, RSet(Str(HeureFuseau(#Cmb_Fuseau_4)%24), 2, "0")+":"+RSet(Str(MinuteFuseau(#Cmb_Fuseau_4)%60), 2, "0") + ":" + RSet(Str(Second(Date())), 2, "0"))
          EndIf
      EndSelect          
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Cmb_Fuseau_1
          Calcul_FH(#Cmb_Fuseau_1)
          SetGadgetText(#Str_Fuseau_1, RSet(Str(HeureFuseau(#Cmb_Fuseau_1)%24), 2, "0")+":"+RSet(Str(MinuteFuseau(#Cmb_Fuseau_1)%60), 2, "0") + ":" + RSet(Str(Second(Date())), 2, "0"))
        Case #Cmb_Fuseau_2
          Calcul_FH(#Cmb_Fuseau_2)
          SetGadgetText(#Str_Fuseau_2, RSet(Str(HeureFuseau(#Cmb_Fuseau_2)%24), 2, "0")+":"+RSet(Str(MinuteFuseau(#Cmb_Fuseau_2)%60), 2, "0") + ":" + RSet(Str(Second(Date())), 2, "0"))
        Case #Cmb_Fuseau_3
          Calcul_FH(#Cmb_Fuseau_3)
          SetGadgetText(#Str_Fuseau_3, RSet(Str(HeureFuseau(#Cmb_Fuseau_3)%24), 2, "0")+":"+RSet(Str(MinuteFuseau(#Cmb_Fuseau_3)%60), 2, "0") + ":" + RSet(Str(Second(Date())), 2, "0"))
        Case #Cmb_Fuseau_4
          Calcul_FH(#Cmb_Fuseau_4)
          SetGadgetText(#Str_Fuseau_4, RSet(Str(HeureFuseau(#Cmb_Fuseau_4)%24), 2, "0")+":"+RSet(Str(MinuteFuseau(#Cmb_Fuseau_4)%60), 2, "0") + ":" + RSet(Str(Second(Date())), 2, "0"))
      EndSelect
      
    Case #PB_Event_CloseWindow
      Select EventWindow()
        Case #Fenetre_Fuseaux
          CloseWindow(#Fenetre_Fuseaux)
          Break
      EndSelect
  EndSelect
ForEver

;- données
DataSection
  Debut:
  Data.s " 00:00", "Casablanca"
  Data.s " 00:00", "Dublin, Edimbourg, Lisbonne, Londres"
  Data.s " 00:00", "Monrovia, Reyjavik"
  Data.s "+01:00", "Affrique centrale - ouest"
  Data.s "+01:00", "Belgrade, Bratislava, Budapest, Ljubjana, Prague"
  Data.s "+01:00", "Bruxelles, Copenhague"
  Data.s "+01:00", "Madrid, Paris"
  Data.s "+01:00", "Sarajevo, Skpje, Varsovie, Zagreb"
  Data.s "+01:00", "Windhoek"
  Data.s "+02:00", "Amman"
  Data.s "+02:00", "Athènes, Bucarest"
  Data.s "+02:00", "Beyrouth"
  Data.s "+02:00", "Chisinau"
  Data.s "+02:00", "Damas"
  Data.s "+02:00", "Gaza, Hébron"
  Data.s "+02:00", "Hrare, Pretoria"
  Data.s "+02:00", "Helsinki, Kiev, Riga, Sofia, Tallin, Vilnius"
  Data.s "+02:00", "Jérusalem"
  Data.s "+02:00", "Kaliningrad"
  Data.s "+02:00", "Le Caire"
  Data.s "+02:00", "Tripoli"
  Data.s "+03:00", "Bagdad"
  Data.s "+03:00", "Istanbul"
  Data.s "+03:00", "Koweit, Riyad"
  Data.s "+03:00", "Misnk"
  Data.s "+03:00", "Moscou, Saint-Petersbourg, Volgograd"
  Data.s "+03:00", "Nairobi"
  Data.s "+03:30", "Téhéran"
  Data.s "+04:00", "Abu Dhabi, Muscat"
  Data.s "+04:00", "Astrajhan, Oulianovsk"
  Data.s "+04:00", "Bakou"
  Data.s "+04:00", "Erevan"
  Data.s "+04:00", "Izhevsk, Samara"
  Data.s "+04:00", "Port Louis"
  Data.s "+04:00", "Saratov"
  Data.s "+04:00", "Tbilissi"
  Data.s "+04:30", "Kaboul"
  Data.s "+05:00", "Achgabat, Tachkent"
  Data.s "+05:00", "Iekaterinbourg"
  Data.s "+05:00", "Islamabad, Karachi"
  Data.s "+05:30", "Chennai, Kolkata, Mumbai, New Delhi"
  Data.s "+05:30", "Sri Jayawardenepura"
  Data.s "+05:45", "Katmandou"
  Data.s "+06:00", "Astana"
  Data.s "+06:00", "Dhaka"
  Data.s "+06:00", "Omsk"
  Data.s "+06:30", "Rangoon"  
  Data.s "+07:00", "Bangkok, Hanoi, Djakarta"  
  Data.s "+07:00", "Barnaoul, Gorno-Altaïsk"
  Data.s "+07:00", "Hovd"
  Data.s "+07:00", "Krasnoïarsk"
  Data.s "+07:00", "Novosibirsk"
  Data.s "+07:00", "Tomsk"
  Data.s "+08:00", "Pékin, Chongqing, Hong Kong, Urumqi"
  Data.s "+08:00", "Irkoutsk"
  Data.s "+08:00", "Kuala Lumpur, Singapour"
  Data.s "+08:00", "Oulan-Bator"
  Data.s "+08:00", "Perth"
  Data.s "+08:00", "Taipei"
  Data.s "+08:30", "Pyongyang"
  Data.s "+08:45", "Eucla"
  Data.s "+09:00", "Chita"
  Data.s "+09:00", "Iakoutsk"
  Data.s "+09:00", "Osaka, Sapporo, Tokyo"
  Data.s "+09:00", "Séoul"
  Data.s "+09:30", "Adélaïde"
  Data.s "+09:30", "Darwin"
  Data.s "+10:00", "Brisbane"
  Data.s "+10:00", "Canberra, Melbourne, Sydney"
  Data.s "+10:00", "Guam, Port Moresby"
  Data.s "+10:00", "Hobort"
  Data.s "+10:00", "Vladivostok"
  Data.s "+10:30", "Île Lord Howe"
  Data.s "+11:00", "Chokurdakh"
  Data.s "+11:00", "Madagan"
  Data.s "+11:00", "Sakhaline"
  Data.s "+11:00", "Île Bougainville"
  Data.s "+11:00", "Île Norfolk"
  Data.s "+11:00", "Îles Salomon, Nouvelle-Calédonie"
  Data.s "+12:00", "Anadyr, Petropavlovsk-Kamtchatski"
  Data.s "+12:00", "Auckland, Wellington"
  Data.s "+12:00", "Fidji"
  Data.s "+12:45", "Îles Chatham"
  Data.s "+13:00", "Nuku'alofa"
  Data.s "+13:00", "Samoa"
  Data.s "+14:00", "Île Kiritimati"
  Data.s "-01:00", "Îles du Cap-Vert"
  Data.s "-01:00", "Les Açores"
  Data.s "-03:00", "Araguaina"
  Data.s "-03:00", "Brasilia"
  Data.s "-03:00", "Buenos Aires"
  Data.s "-03:00", "Cayenne, Fortaleza"
  Data.s "-03:00", "Groenland"
  Data.s "-03:00", "Montevideo"
  Data.s "-03:00", "Punta Arenas"
  Data.s "-03:00", "Saint-Pierre-et-Miquelon"
  Data.s "-03:00", "Salvador"
  Data.s "-03:00", "Terre-Neuve-et-Labrador"
  Data.s "-04:00", "Asuncion"
  Data.s "-04:00", "Caracas"
  Data.s "-04:00", "Cuiaba"
  Data.s "-04:00", "Georgetown, La Paz, Manaus, San Juan"
  Data.s "-04:00", "Santiago"
  Data.s "-04:00", "Îles Turques-et-Caïques"
  Data.s "-05:00", "Bogota, Lima, Quito, Rio Branco"
  Data.s "-05:00", "La Havane"
  Data.s "-05:00", "Haïti"
  Data.s "-06:00", "Île de Pâques"
  Data.s "-06:00", "Guadalajara, Mexico, Monterrey"
  Data.s "-06:00", "Saskatchewan"
  Data.s "-06:00", "Amérique centrale"
  Data.s "-07:00", "Arizona"
  Data.s "-07:00", "Chihuahua, Mazatlan"
  Data.s "-07:00", "Montagnes Rocheuses"
  Data.s "-08:00", "Basse Californie"
  Data.s "-08:00", "Pacifique, E.U., Canada"
  Data.s "-09:00", "Alaska"
  Data.s "-09:30", "Île Marquises"
  Data.s "-10:00", "Îles Aléoutiennes"
  Data.s "-10:00", "Hawaii"
  Data$ "Fin", ""
  Fin:
EndDataSection

Re: Calculatrice Micoute (Fuseaux horaires)

Publié : dim. 19/nov./2017 12:04
par Zorro
ya un truc qui ne fonctionne pas avec ton prg

a Tahiti , il y a -11:00 de décalage, en ce moment (heure d'hiver en France ) .... il n'y a pas d'heure d'été a Tahiti !
et donc, il y a -12:00de décalage en été a Tahiti par rapport a la France

mais si j'ajoute un Data

Code : Tout sélectionner

 Data.s "-11:00","Tahiti"
ça m'affiche une heure négative !! et avec une heure de décalage

si je met

Code : Tout sélectionner

 Data.s "-12:00","Tahiti"
l'heure a l'air bonne , mais toujours négative ....

(a Tahiti au moment ou j'ecris (Dimanche) ; ils sont encore a Samedi )

Re: Calculatrice Micoute (Fuseaux horaires)

Publié : dim. 19/nov./2017 14:33
par Micoute
Code remis à jour.

Re: Calculatrice Micoute (Fuseaux horaires)

Publié : dim. 19/nov./2017 15:26
par Zorro
bien ! :)

Re: Calculatrice Micoute (Fuseaux horaires)

Publié : lun. 20/nov./2017 22:01
par Mouillard
Merci Micoute :)

>Merci pour le partage, et pour toutes les réponses à tous ces calculs instantanés....///

Qu'elle inspiration tu as. B Bravo :D