j'ai fait ces petites procédures dans le cadre d'un programme où j'avais besoin de formater des dates dans différents systèmes.
Ce logiciel est libre de droits et vous pouvez le modifier à votre guise.
Code : Tout sélectionner
;Déclaration des Procédures
Declare.s MoisEnTexte(Pays.s)
Declare.s JourEnTexte(Pays.s)
Declare.s SetCentury(Pays.s)
Global.s Pays
CompilerIf #PB_Compiler_IsMainFile
;Sortie des chaines requises
Debug "France: " + SetCentury("France")
Debug "Allemagne: " + SetCentury("Allemagne")
Debug "Etats-Unis: " + SetCentury("Etats-Unis")
Debug "Japon: " + SetCentury("Japon")
CompilerEndIf
;Procédures utilisées
Procedure.s SetCentury(Pays.s)
Select Pays
Case "France","Belgique","Royaume-uni"
FormatDate("%dd/%mm/%yyyy", Date())
ProcedureReturn JourEnTexte(Pays) + " " +FormatDate("%dd", Date()) + " " + MoisEnTexte(Pays) + FormatDate(" %yyyy", Date())
Case "Allemagne"
FormatDate("%dd.%mm.%yyyy", Date())
ProcedureReturn JourEnTexte(Pays) + ", " + FormatDate("%mm", Date()) + ". " + MoisEnTexte(Pays) + FormatDate(" %yyyy", Date())
Case "Etats-Unis"
FormatDate("%yyyy/%dd/%mm", Date())
ProcedureReturn JourEnTexte(Pays) + ", " + MoisEnTexte(Pays) + FormatDate(" %dd, %yyyy", Date())
Case "Chine","Japon"
FormatDate("%yyyy/%mm/%dd", Date())
ProcedureReturn FormatDate("%yyyy ", Date()) + MoisEnTexte(Pays) + " " + FormatDate("%dd ", Date()) + JourEnTexte(Pays)
EndSelect
EndProcedure
Procedure.s JourEnTexte(Pays.s)
Protected j$
Select Pays.s
Case "France"
Select DayOfWeek(Date())
Case 1: j$="Lundi"
Case 2: j$="Mardi"
Case 3: j$="Mercredi"
Case 4: j$="Jeudi"
Case 5: j$="Vendredi"
Case 6: j$="Samedi"
Default: j$="Dimanche"
EndSelect
Case "Allemagne"
Select DayOfWeek(Date())
Case 1: j$="Montag"
Case 2: j$="Dienstag"
Case 3: j$="Mittwoch"
Case 4: j$="Donnerstag"
Case 5: j$="Freitag"
Case 6: j$="Samstag"
Default: j$="Sonntag"
EndSelect
Case "Royaume-uni","Etats-Unis"
Select DayOfWeek(Date())
Case 1: j$="Monday"
Case 2: j$="Tuesday"
Case 3: j$="Wednesday"
Case 4: j$="Thursday"
Case 5: j$="Friday"
Case 6: j$="Saturday"
Default: j$="Sunday"
EndSelect
Case "Chine"
Select DayOfWeek(Date())
Case 1: j$="yuèyàorì"
Case 2: j$="huǒyàorì"
Case 3: j$="shuǐyàorì"
Case 4: j$="mùyàorì"
Case 5: j$="jīnyàorì"
Case 6: j$="tǔyàorì"
Default: j$="rìyàorì"
EndSelect
Case "Japon"
Select DayOfWeek(Date())
Case 1: j$="getsuyōbi"
Case 2: j$="kayōbi"
Case 3: j$="suiyōbi"
Case 4: j$="mokuyōbi"
Case 5: j$="kin'yōbi"
Case 6: j$="doyōbi"
Default: j$="nichiyōbi"
EndSelect
EndSelect
ProcedureReturn j$
EndProcedure
Procedure.s MoisEnTexte(Pays.s)
Protected m$
Select Pays.s
Case "France"
Select Month(Date())
Case 1: m$="Janvier"
Case 2: m$="Février"
Case 3: m$="Mars"
Case 4: m$="Avril"
Case 5: m$="Mai"
Case 6: m$="Juin"
Case 7: m$="Juillet"
Case 8: m$="Août"
Case 9: m$="Septembre"
Case 10:m$="Octobre"
Case 11:m$="Novembre"
Default:m$="Décembre"
EndSelect
Case "Allemagne"
Select Month(Date())
Case 1: m$="Januar"
Case 2: m$="Februar"
Case 3: m$="März"
Case 4: m$="April"
Case 5: m$="Mai"
Case 6: m$="Juni"
Case 7: m$="Juli"
Case 8: m$="August"
Case 9: m$="September"
Case 10: m$="Oktober"
Case 11: m$="November"
Default:m$="Dezember"
EndSelect
Case "Royaume-uni","Etats-Unis"
Select Month(Date())
Case 1: m$="January"
Case 2: m$="February"
Case 3: m$="March"
Case 4: m$="April"
Case 5: m$="May"
Case 6: m$="June"
Case 7: m$="July"
Case 8: m$="August"
Case 9: m$="September"
Case 10: m$="October"
Case 11: m$="November"
Default:m$="December"
EndSelect
Case "Chine"
Select Month(Date())
Case 1: m$="lìchūn"
Case 2: m$="jīngzhé"
Case 3: m$="qīngmíng"
Case 4: m$="lìxià"
Case 5: m$="mángzhòng "
Case 6: m$="xiǎoshǔ"
Case 7: m$="lìqiū"
Case 8: m$="báilù"
Case 9: m$="hánlù"
Case 10: m$="lìdōng"
Case 11: m$="dàxuě"
Default:m$="xiǎohán"
EndSelect
Case "Japon"
Select Month(Date())
Case 1: m$="mutsuki"
Case 2: m$="kisaragi"
Case 3: m$="yayoi"
Case 4: m$="uzuki"
Case 5: m$="satsuki"
Case 6: m$="minasuki"
Case 7: m$="fumisuki"
Case 8: m$="hazuki"
Case 9: m$="nagatsuki"
Case 10: m$="kannazuki"
Case 11: m$="shimotsuki"
Default:m$="shiwazu"
EndSelect
EndSelect
ProcedureReturn m$
EndProcedure