comme j'aime bien compter le temps qui passe, je me suis inspiré de différents modules récoltés par-ci, par-là sur différents forums, j'ai donc décidé de m'en faire un pour moi, comme je le trouve très utile, j'en profite pour vous l'offrir à vous tous à qui je dois beaucoup.
DECLARATION DU MODULE
Code : Tout sélectionner
; Description: fonctions de date avec chiffres quad (Années 0000-9999)
EnableExplicit
DeclareModule DateQ
;{ Enumération
Enumeration
#Date_AnneeQ
#Date_MoisQ
#Date_SemaineQ
#Date_JourQ
#Date_HeureQ
#Date_MinuteQ
#Date_SecondeQ
EndEnumeration
;}
;{ Structure
Structure sDiffTemps
TotalJours.q
JoursRestants.q
Annees.q
Mois.q
Heures.q
Minutes.q
Secondes.q
sTotalJours.s
sJoursRestants.s
sAnnees.s
sMois.s
sHeures.s
sMinutes.s
sSecondes.s
EndStructure
Structure Temps
Annee.w
Mois.w
JourDeSemaine.w
Jour.w
Heure.w
Minute.w
Seconde.w
Milliseconde.w
EndStructure
Structure StrucSaisons
Printemps.i[22]
Ete.i[22]
Automne.i[22]
Hiver.i[22]
EndStructure
Structure StrucSoleil
Lever$
Coucher$
EndStructure
Structure sFetes
Index.i
Fete.s
Date.s
EndStructure
;}
;{ Constantes
#SecsParJourQ = 86400
#UniteTemps = "an|s,mois,jour|s,heure|s,minute|s,seconde|s"
;}
;{ Variables
Global UniteDateQ.q = 10000000 ; Unité de granularité, initialement 1 seconde pour la compatibilité avec les routines date de PB 4.xx
Global UniteJourQ.q = 86400 ; Nombre de granularité unités par jour
Global MaDiff.sDiffTemps, *Soleil.StrucSoleil=AllocateStructure(StrucSoleil), *J_Saison.StrucSaisons=AllocateStructure(StrucSaisons)
Global NewMap Fetes_Journalieres.sFetes()
Global.s Lever$,Coucher$, Fete$, Date$
Global J_Printemps,J_Ete,J_Automne,J_Hiver
Global Dim TabNomJour$(6), Dim TabNomMois$(11)
TabNomJour$(0) = "dimanche":TabNomJour$(1) = "lundi ":TabNomJour$(2) = "mardi ":TabNomJour$(3) = "mercredi"
TabNomJour$(4) = "jeudi ":TabNomJour$(5) = "vendredi":TabNomJour$(6) = "samedi "
TabNomMois$(0) = "janvier ":TabNomMois$(1) = "février ":TabNomMois$(2) = "mars ":TabNomMois$(3) = "avril ":TabNomMois$(4) = "mai ":TabNomMois$(5) = "juin "
TabNomMois$(6) = "juillet ":TabNomMois$(7) = "août ":TabNomMois$(8) = "septembre":TabNomMois$(9) = "octobre ":TabNomMois$(10) = "novembre ":TabNomMois$(11) = "décembre "
;}
;{ Section de données : dates des saisons de 2016 à 2037 et fêtes à souhaite
DataSection
Printemps:
Data.s "20/03/2016","20/03/2017","20/03/2018","20/03/2019",
"20/03/2020","20/03/2021","20/03/2022","20/03/2023",
"20/03/2024","20/03/2025","20/03/2026","20/03/2027",
"20/03/2028","20/03/2029","20/03/2030","20/03/2031",
"20/03/2032","20/03/2033","20/03/2034","20/03/2035",
"20/03/2036","20/03/2037"
Ete:
Data.s "21/06/2016","21/06/2017","21/06/2018","21/06/2019",
"20/06/2020","21/06/2021","21/06/2022","21/06/2023",
"20/06/2024","21/06/2025","21/06/2026","21/06/2027",
"20/06/2028","21/06/2029","21/06/2030","21/06/2031",
"20/06/2032","21/06/2033","21/06/2034","21/06/2035",
"20/06/2036","21/06/2037"
Automne:
Data.s "22/09/2016","22/09/2017","23/09/2018","23/09/2019",
"22/09/2020","22/09/2021","23/09/2022","23/09/2023",
"22/09/2024","22/09/2025","23/09/2026","23/09/2027",
"22/09/2028","22/09/2029","23/09/2030","23/09/2031",
"22/09/2032","22/09/2033","23/09/2034","23/09/2035",
"22/09/2036","22/09/2037"
Hiver:
Data.s "21/12/2016","21/12/2017","21/12/2018","22/12/2019",
"21/12/2020","21/12/2021","21/12/2022","22/12/2023",
"21/12/2024","21/12/2025","21/12/2026","22/12/2027",
"21/12/2029","21/12/2029","21/12/2030","22/12/2031",
"21/12/2032","21/12/2033","21/12/2034","22/12/2035",
"21/12/2036","21/12/2037"
fetes:
Data.s "Jour de l'an","01/01", "Basile","02/01","Geneviève","03/01","Odilon","04/01","Edouard","05/01","Mélaine","06/01"
Data.s "Raymond","07/01","Lucien","08/01","Alix","09/01","Guillaume","10/01","Pauline","11/01"
Data.s "Tatiana","12/01","Yvette","13/01","Nina","14/01","Rémi","15/01","Marcel","16/01"
Data.s "Roseline","17/01","Prisca","18/01","Marius","19/01","Sébastien","20/01","Agnès","21/01"
Data.s "Vincent","22/01","Barnard","23/01","François de Sales","24/01","Conversion de Paul","25/01"
Data.s "Paule","26/01","Angèle","27/01","Thomas d'Aquin","28/01","Gildas","29/01","Martine","30/01"
Data.s "Marcelle","31/01","Ella","01/02","Présentation","02/02","Blaise","03/02","Véronique","04/02"
Data.s "Agathe","05/02","Gaston","06/02","Eugènie","07/02","Jacqueline","08/02","Apolline","09/02"
Data.s "Arnaud","10/02","Notre Dame de Lourdes","11/02","Félix","12/02","Béatrice","13/02"
Data.s "Valentin","14/02","Claude","15/02","Julienne","16/02","Alexis","17/02","Bernadette","18/02"
Data.s "Gabin","19/02","Aimée","20/02","Damien","21/02","Isabelle","22/02","Lazare","23/02"
Data.s "Modeste","24/02","Roméo","25/02","Nestor","26/02","Honorine","27/02","Romain","28/02"
Data.s "Aubin","01/03","Charles le Bon","02/03","Guénolé","03/03","Casimir","04/03","Olive","05/03"
Data.s "Colette","06/03","Félicité","07/03","Jean de Dieu","08/03","Françoise","09/03","Vivien","10/03"
Data.s "Rosine","11/03","Justine","12/03","Rodrigue","13/03","Mathilde","14/03","Louise","15/03"
Data.s "Bénédicte","16/03","Patrice","17/03","Cyrille","18/03","Joseph","19/03","Anatole","20/03"
Data.s "Clémence","21/03","Léa","22/03","Victorien","23/03","Catherine","24/03","Annonciation","25/03"
Data.s "Larissa","26/03","Habib","27/03","Gontran","28/03","Gwladys","29/03","Amédée","30/03"
Data.s "Benjamin","31/03","Hugues","01/04","Sandrine","02/04","Richard","03/04","Isidore","04/04"
Data.s "Irène","05/04","Marcellin","06/04","Jean-Baptiste de la Salle","07/04","Julie","08/04"
Data.s "Gautier","09/04","Fulbert","10/04","Stanislas","11/04","Jules","12/04","Ida","13/04"
Data.s "Maxime","14/04","Paterne","15/04","Benoît-Joseph","16/04","Anicet","17/04","Parfait","18/04"
Data.s "Emma","19/04","Odette","20/04","Anselme","21/04","Alexandre","22/04","Georges","23/04"
Data.s "Fidèle","24/04","Marc","25/04","Alida","26/04","Zita","27/04","Valérie","28/04"
Data.s "Catherine de Sienne","29/04","Robert","30/04","Fête du travail", "01/05","Boris","02/05","Philippe / Jacques","03/05"
Data.s "Sylvain","04/05","Judith","05/05","Prudence","06/05","Gisèle","07/05","Jeanne d'Arc","08/05","Pacôme","09/05"
Data.s "Solange","10/05","Estelle","11/05","Achille","12/05","Rolande","13/05","Matthias","14/05"
Data.s "Denise","15/05","Honoré","16/05","Pascal","17/05","Eric","18/05","Yves","19/05"
Data.s "Bernardin","20/05","Constantin","21/05","Emile","22/05","Didier","23/05","Donatien","24/05"
Data.s "Sophie","25/05","Bérenger","26/05","Augustin","27/05","Germain","28/05","Aymar","29/05"
Data.s "Ferdinand","30/05","Visitation de la Sainte Vierge","31/05","Justin","01/06","Blandine","02/06"
Data.s "Kévin","03/06","Clotilde","04/06","Igor","05/06","Norbert","06/06","Gilbert","07/06"
Data.s "Médard","08/06","Diane","09/06","Landry","10/06","Barnabé","11/06","Guy","12/06"
Data.s "Antoine de Padoue","13/06","Elisée","14/06","Germaine","15/06","Jean-François / Régis","16/06"
Data.s "Hervé","17/06","Léonce","18/06","Romuald","19/06","Silvère","20/06","Héraclide / Rodolphe","21/06"
Data.s "Alban","22/06","Audrey","23/06","Jean-Baptiste","24/06","Prosper","25/06","Anthelme","26/06"
Data.s "Fernand","27/06","Irénée","28/06","Pierre / Paul","29/06","Martial","30/06","Thierry","01/07"
Data.s "Martinien","02/07","Thomas","03/07","Florent","04/07","Antoine","05/07","Mariette","06/07"
Data.s "Raoul","07/07","Thibault","08/07","Amandine","09/07","Ulrich","10/07","Benoît","11/07"
Data.s "Olivier","12/07","Henri / Joël","13/07","Fête nationale","14/07","Donald","15/07","Notre Dame du Mont Carmel","16/07"
Data.s "Charlotte","17/07","Frédéric","18/07","Arsène","19/07","Marina","20/07","Victor","21/07"
Data.s "Marie-Madeleine","22/07","Brigitte","23/07","Christine","24/07","Jacques","25/07"
Data.s "Anne / Joachin","26/07","Nathalie","27/07","Samson","28/07","Marthe","29/07","Juliette","30/07"
Data.s "Ignace de Loyola","31/07","Alphonse","01/08","Julien / Eymard","02/08","Lydie","03/08"
Data.s "Jean-Marie Vianney","04/08","Abel","05/08","Transfiguration","06/08","Gaétan","07/08"
Data.s "Dominique","08/08","Amour","09/08","Laurent","10/08","Claire","11/08","Clarisse","12/08"
Data.s "Hippolyte","13/08","Evrard","14/08","Assomption","15/08","Armel","16/08","Hyacinthe","17/08","Hélène","18/08"
Data.s "Jean-Eudes","19/08","Bernard","20/08","Christophe","21/08","Fabrice","22/08"
Data.s "Rose de Lima","23/08","Barthélémy","24/08","Louis","25/08","Natacha","26/08","Monique","27/08"
Data.s "Augustin","28/08","Sabine","29/08","Fiacre","30/08","Aristide","31/08","Gilles","01/09"
Data.s "Ingrid","02/09","Grégoire","03/09","Rosalie","04/09","Raïssa","05/09","Bertrand","06/09"
Data.s "Reine","07/09","Nativité","08/09","Alain","09/09","Inès","10/09","Adelphe","11/09"
Data.s "Apollinaire","12/09","Aimé","13/09","Croix Glorieuse","14/09","Roland","15/09","Edith","16/09"
Data.s "Renaud","17/09","Nadège","18/09","Emilie","19/09","Davy","20/09","Matthieu","21/09"
Data.s "Maurice","22/09","Constant", "23/09","Thècle","24/09","Hermann","25/09","Côme / Damien","26/09"
Data.s "Vincent de Paul","27/09","Venceslas","28/09","Michel / Gabriel / Raphaël","29/09"
Data.s "Jérôme","30/09","Thérèse de l' Enfant Jésus","01/10","Léger","02/10","Gérard","03/10"
Data.s "François d'Assise","04/10","Fleur","05/10","Bruno","06/10","Serge","07/10","Pélagie","08/10"
Data.s "Denis","09/10","Ghislain","10/10","Firmin","11/10","Wilfried","12/10","Géraud","13/10"
Data.s "Juste","14/10","Thérèse d'Avila","15/10","Edwige","16/10","Baudoin","17/10","Luc","18/10"
Data.s "René","19/10","Adeline","20/10","Céline","21/10","Elodie","22/10","Jean de Capistran","23/10"
Data.s "Florentin","24/10","Crépin","25/10","Dimitri","26/10","Emeline","27/10","Jude","28/10"
Data.s "Narcisse","29/10","Bienvenu","30/10","Quentin","31/10","Toussaint","01/11","Défunts","02/11"
Data.s "Hubert","03/11","Charles","04/11","Sylvie","05/11","Bertille","06/11","Carine","07/11"
Data.s "Geoffroy","08/11","Théodore","09/11","Léon","10/11","Armistice 14-18","11/11","Christian","12/11","Brice","13/11"
Data.s "Sidoine","14/11","Albert","15/11","Marguerite","16/11","Elisabeth","17/11","Aude","18/11"
Data.s "Tanguy","19/11","Edmond","20/11","Christ Roi / Prés de Marie", "21/11","Cécile","22/11"
Data.s "Clément","23/11","Flora","24/11","Catherine","25/11","Delphine","26/11","Sévrin","27/11"
Data.s "Jacques de la Marche","28/11","Saturnin","29/11","André","30/11","Florence","01/12"
Data.s "Viviane","02/12","François-Xavier","03/12","Barbara","04/12","Gérald","05/12","Nicolas","06/12"
Data.s "Ambroise","07/12","Immaculée Conception","08/12","Pierre Fourier","09/12","Romaric","10/12"
Data.s "Daniel","11/12","Jeanne-Françoise de Chantal","12/12","Lucie","13/12","Odile","14/12"
Data.s "Ninon","15/12","Alice","16/12","Gaël","17/12","Gatien","18/12","Urbain","19/12"
Data.s "Théophile","20/12","Pierre Canisius", "21/12","Françoise-Xavière","22/12","Armand","23/12"
Data.s "Adèle","24/12","Emmanuel", "25/12","Etienne","26/12","Jean","27/12","Innocents","28/12"
Data.s "David","29/12","Roger","30/12","Sylvestre","31/12","Auguste","29/02"
EndDataSection
;}
;{ Déclaration des procédures
Declare SiAnneeBissextileQ(Annee.q) ;Indique si l'année donnée est bissextile
Declare.b SiBissextile(Annee=-1)
Declare JoursDansMoisQ(Annee, Mois) ;Retoure le nombre de jours dans le mois donné
Declare.q DateQ() ;Retourne le nombre de secondes écoulées depuis le 1er Janvier 0001
Declare.q DateQ2(Annee, Mois, Jour, Heure = 0, Minute = 0, Seconde = 0) ;Retourne la date julienne de la date donnée
Declare.b SecondeQ(Date.q) ;Retourne la valeur de la seconde de la date spécifiée (entre 0 et 59).
Declare.b MinuteQ(Date.q) ;Retourne la valeur de la minute de la date spécifiée (entre 0 et 59).
Declare.b HeureQ(Date.q) ;Retourne la valeur de l'heure de la date spécifiée (entre 0 et 23).
Declare.b JourQ(Date.q) ;Retourne la valeur du jour de la date spécifiée (entre 1 et 31).
Declare.b MoisQ(Date.q) ;Retourne la valeur du mois de la date spécifiée (entre 1 et 12).
Declare.w AnneeQ(Date.q) ;Retourne la valeur de l'année de la date spécifiée (entre 0 et 9999).
Declare.w JourDAnneeQ(Date.q) ;Retourne le nombre de jours écoulés depuis le début de l'année de la date spécifiée (entre 1 et 366).
Declare.b JourDeSemaineQ(Date.q) ;Renvoie la valeur du jour dans la semaine de la date spécifiée (0 = dimanche, 6 = samedi).
Declare.q AjouterDateQ(Date.q, Champ.b, Compensation.q) ;Retourne une nouvelle date.
Declare.s FormatDateQ(Masque.s, Date.q) ;Retourne une représentation de chaîne de la date, selon le masque spécifié
Declare.q AnalyserDateQ(masque.s, Date.s) ;Retourne une représentation de chaîne de la date, selon le masque spécifié
Declare.s NomMoisQ(Date.q) ;Retourne le nom du mois donné.
Declare.s NomJourSemaineQ(Date.q) ;Retourne le nom du jour de la semaine de la date donnée.
Declare.i SemaineDAnneeQ(date.q=-1, Premier_Jour=0) ;Retourne le nombre de semaines (1 .. 53) écoulées depuis le début de l'année pour la date donnée.
Declare.i DateSemaine1Q(Annee=-1, Premier_Jour=0) ;Renvoie la première date de janvier de la semaine
Declare.q AujourdhuiQ() ;Renvoie la date actuelle
Declare.q Aujourdhui_0Q() ;Renvoie la date actuelle à minuit
Declare.q NbreJoursRestantsMois() ;Renvoie le nombre de jours pour finir le mois en cours
Declare.q NbreJoursRestantsAnnee() ;Renvoie le nombre de jours pour finir l'année en cours
Declare.q DiffDatesQ(datedebut.q, datefin.q=-1, Unite=#Date_JourQ, multiple.q=1) ; Différence entre deux dates
Declare.q DateDiffQ(dateAvant,dateApres,*diff.sDiffTemps) ;Calcule la difference entre 2 dates en années, mois, jours, heures, minutes et secondes
Declare.s AjouterUniteTemps(nombre.q, unite.q)
Declare.s DiffTempsQ(Secondes.q)
Declare.s Premier_Ouvre_Mois(Annee,Mois)
Declare ChercherVendredi13(Annee,Mois)
Declare.q DatePaques(Annee.q=0) ; Retourne la date du dimanche de Pâques pour l'année donnée (valable jusqu'à 4099)
Declare.q Paques(annee.l = -1)
Declare Mardi_Gras(annee.l = -1)
Declare Cendres(annee.l = -1)
Declare Passion(annee.l = -1)
Declare Rameaux(annee.l = -1)
Declare Jeudi_Saint(annee.l = -1)
Declare Vendredi_Saint(annee.l = -1)
Declare.q PaquesLundi(annee.l = -1)
Declare.q Ascension(annee.l = -1)
Declare.q Pentecote(annee.l = -1)
Declare.q PentecoteLundi(annee.l = -1)
Declare.q Trinite(annee.l = -1)
Declare.q NouvelAn(annee.l = -1)
Declare.q FeteDuTravail(annee.l = -1)
Declare.q Victoire1945(annee.l = -1)
Declare.q FeteNationale(annee.l = -1)
Declare.q Assomption(annee.l = -1)
Declare.q Toussaint(annee.l = -1)
Declare.q Armistice(annee.l = -1)
Declare.q PremierDimanche_Avent(annee.l = - 1)
Declare.q DeuxiemeDimanche_Avent(annee.l = - 1)
Declare.q TroisiemeDimanche_Avent(annee.l = - 1)
Declare.q Quatrieme_Dimanche_Avent(annee.l = -1)
Declare.q Noel(annee.l = -1)
Declare.q Saint_Sylvestre(annee.l = -1)
Declare.q Fete_des_grand_meres(annee = -1)
Declare.q Fete_des_meres(annee.l = -1)
Declare.q Fete_des_peres(annee = -1)
Declare.q Fete_des_grand_peres(annee= -1)
Declare CalculerSoleil(lat.f,lon.f,JA,tz.d)
Declare.s Lever_Soleil(lat.f,lon.f,JA)
Declare.s Coucher_Soleil(lat.f,lon.f,JA)
Declare.i DecalageHoraire(type) ; Retourne l'heure de la zone d'information de polarisation
Declare.s ZoneFuseau() ; Retourne le nom du fuseau horaire
Declare.b JoursDansMois(Annee=-1,Mois=-1)
Declare TrouverPremierDimanche(Annee,Mois)
Declare TrouverDeuxiemeDimanche(Annee,Mois)
Declare TrouverTroisiemeDimanche(Annee,Mois)
Declare TrouverQuatriemeDimanche(Annee,Mois)
Declare TrouverDernierDimanche(Annee,Mois)
Declare$ SigneAstro(Jour,Mois);Permet de déterminer le signe astrologique correspondant au jour et au mois donnés
Declare$ Element_Astro(Jour, Mois)
Declare$ Saison(nJour,nMois);Permet de déterminer la saison correspondant au jour et au mois donnés
Declare Heure_d_ete(Annee=-1)
Declare Heure_d_hiver(Annee=-1)
Declare.s Calculer_Age(A_avant, M_avant, J_avant, A_apres, M_apres, J_apres)
Declare Anniversaire_Dans(AnneeNaissance, MoisNaissance, JourNaissance)
Declare Calculer_Date_Anniversaire(AnneeNaissance, MoisNaissance, JourNaissance)
Declare.s Decomposer_Anniversaire(AnneeNaissance, MoisNaissance, JourNaissance)
;}
;{ Saisons
Global Z, *Saison.StrucSaisons=AllocateStructure(StrucSaisons)
Global.s Date_Printemps,Date_Ete,Date_Automne,Date_Hiver
Restore Printemps
For Z = 0 To 21
Read.s Date_Printemps
*Saison\Printemps[Z] = AnalyserDateQ("%dd/%mm/%yyyy",Date_Printemps)
*J_Saison\Printemps[Z]=JourDAnneeQ(*Saison\Printemps[Z])
Next Z
Restore Ete
For Z = 0 To 21
Read.s Date_Ete
*Saison\Ete[Z]=AnalyserDateQ("%dd/%mm/%yyyy",Date_Ete)
*J_Saison\Ete[Z]=JourDAnneeQ(*Saison\Ete[Z])
Next Z
Restore Automne
For Z = 0 To 21
Read.s Date_Automne
*Saison\Automne[Z]=AnalyserDateQ("%dd/%mm/%yyyy",Date_Automne)
*J_Saison\Automne[Z]=JourDAnneeQ(*Saison\Automne[Z])
Next Z
Restore Hiver
For Z = 0 To 21
Read.s Date_Hiver
*Saison\Hiver[Z]=AnalyserDateQ("%dd/%mm/%yyyy",Date_Hiver)
*J_Saison\Hiver[Z]=JourDAnneeQ(*Saison\Hiver[Z])
Next Z
;}
;{ Fêtes à souhaiter
Restore fetes
For z = 0 To 365
Read$ Fete$
Read$ Date$
AddMapElement(Fetes_Journalieres(), Str(z))
Fetes_Journalieres()\Index = z
Fetes_Journalieres()\Fete = Fete$
Fetes_Journalieres()\Date = Date$
Next z
;}
EndDeclareModule
/code-pb]