users_user-20.html - [VB] Savoir si un jour est ouvré ou pas (fériés + Week-End)
- Public Function IsVacant(ByVal dJour As Date) As Boolean
- Dim dPaques As Date
- IsVacant = False
- dPaques = CalcPaques(Year(dJour))
- If (dJour = dPaques + 1) Or (dJour = dPaques + 39) Or (dJour = dPaques + 50) Then IsVacant = True
- If (Day(dJour) = 1) And (Month(dJour) = 1) Then IsVacant = True
- If (Day(dJour) = 1) And (Month(dJour) = 5) Then IsVacant = True
- If (Day(dJour) = 8) And (Month(dJour) = 5) Then IsVacant = True
- If (Day(dJour) = 14) And (Month(dJour) = 7) Then IsVacant = True
- If (Day(dJour) = 15) And (Month(dJour) = 8) Then IsVacant = True
- If (Day(dJour) = 1) And (Month(dJour) = 11) Then IsVacant = True
- If (Day(dJour) = 11) And (Month(dJour) = 11) Then IsVacant = True
- If (Day(dJour) = 25) And (Month(dJour) = 12) Then IsVacant = True
- If (Weekday(dJour) = vbSunday) Or (Weekday(dJour) = vbSaturday) Then IsVacant = True
- End Function
- Public Function CalcPaques(ByVal iAnnee As Integer) As Date
- 'Ascension = 40 jours après pâques
- 'Pentecôte = 50 jours après pâques
- Dim retard As Integer,
- Dim t As Integer
- Dim a As Integer
- Dim b As Integer
- Dim iSiecle As Integer, iJour As Integer
- Dim dPaques As Date
- iSiecle = 1 + iAnnee 100
- If (iSiecle = 20 Or iSiecle = 21) Then
- a = 24
- b = 5
- ElseIf iSiecle = 22 Then
- a = 24
- b = 6
- ElseIf iSiecle = 23 Then
- a = 25
- b = 0
- End If
- retard = (19 * (iAnnee Mod 19) + a) Mod 30
- If retard = 29 Then
- retard = 28
- ElseIf (retard = 28 And (iAnnee Mod 19) > 10) Then
- retard = 27
- End If
- t = (2 * (iAnnee Mod 4) + 4 * (iAnnee Mod 7) + 6 * retard + b) Mod 7
- If retard + t > 9 Then
- iJour = retard + t - 9
- dPaques = DateSerial(iAnnee, 4, iJour)
- Else
- iJour = retard + t + 22
- dPaques = DateSerial(iAnnee, 3, iJour)
- End If
- CalcPaques = dPaques
- End Function
Poster un commentaire