1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| Public Function JourOuvres(ByVal date1 As Date, ByVal Date2 As Date) As Long
Dim DateDeb As Date, DateFin As Date
If IsNull(date1) Or IsNull(Date2) Then GoTo JourOuvres_Erreur
If Not IsDate(date1) Or Not IsDate(Date2) Then GoTo JourOuvres_Erreur
date1 = DateSerial(Year(date1), Month(date1), Day(date1))
Date2 = DateSerial(Year(Date2), Month(Date2), Day(Date2))
If date1 = Date2 Then GoTo JourOuvres_Erreur
DateDeb = date1
DateFin = Date2
If date1 > Date2 Then
DateDeb = Date2
DateFin = date1
End If
JourOuvres = CLng(DateFin) - CLng(DateDeb)
If JourOuvres = 0 Then Exit Function
DateDeb = DateDeb + 1
Do
If (Weekday(DateDeb, vbMonday) >= 6) Or (JourFérié(DateDeb) = True) Then JourOuvres = JourOuvres - 1
DateDeb = DateDeb + 1
Loop While DateDeb < DateFin
Exit Function
JourOuvres_Erreur:
JourOuvres = 0
End Function
Public Function fPaques(wAn%) As Date
'Pâques est le dimanche qui suit le quatorzième jour de la
'Lune qui tombe le 21 mars ou immédiatement après
Dim wA%, wB%, wC%, wD%, wE%, wF%, wG%, wH%
Dim wI%, wJ%, wK%, wL%, wM%, wN%, wP%
wA = wAn Mod 19 'Calcul du rang de l'année dans le cycle lunaire qui a 19 ans
wB = wAn / 100 'Calcul du siècle
wC = wAn Mod 100 'Calcul du rang de l'année dans le siècle
wD = wB / 4
wE = wB Mod 4
wF = (wB + 8) / 25
wG = (wB - wF + 1) / 3
wH = (19 * wA + wB - wD - wG + 15) Mod 30
wI = wC / 4
wK = wC Mod 4
wL = (32 + 2 * wE + 2 * wI - wH - wK) Mod 7
wM = (wA + 11 * wH + 22 * wL) / 451
wN = (wH + wL - 7 * wM + 114) / 31 'détermine le mois
wP = (wH + wL - 7 * wM + 114) Mod 31 'détermine le jour
fPaques = DateSerial(wAn, wN, wP + 1)
'** A titre d'info :************'
'** dtVenSaint = fPaques - 2****'
'** dtLunPaq = fPaques + 1******'
'** dtAscension = fPaques + 39**'
'** dtDimPent = fPaques + 49****'
'** dtLunPent = fPaques + 50****'
End Function
Public Function JourFérié(dtDate As Date) As Boolean
Dim dtPaques As Date
dtPaques = fPaques(Year(dtDate))
Select Case dtDate
Case CDate("01/01/" & Year(dtDate)) 'Jour de l'an
JourFérié = True
Case CDate("01/05/" & Year(dtDate)) 'Fête du travail
JourFérié = True
Case CDate("08/05/" & Year(dtDate)) 'Victoire de 1945
JourFérié = True
Case CDate("14/07/" & Year(dtDate)) 'Fête nationale
JourFérié = True
Case CDate("15/08/" & Year(dtDate)) 'Assomption
JourFérié = True
Case CDate("01/11/" & Year(dtDate)) 'Toussaint
JourFérié = True
Case CDate("11/11/" & Year(dtDate)) 'Armistie 1918
JourFérié = True
Case CDate("25/12/" & Year(dtDate)) 'Noël
JourFérié = True
Case dtPaques + 1 'Lundi de Pâques
JourFérié = True
Case dtPaques + 39 'Ascension
JourFérié = True
Case dtPaques + 50 'Lundi de pentcôte
JourFérié = True
Case Else
JourFérié = False
End Select
End Function |
Partager