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
| Public Function ferie(ByVal DateTest) As Boolean
Dim JJ As Integer, AA As Integer, MM As Integer
Dim NbOr As Integer, Epacte As Integer
Dim PLune As Date, Paques As Date, Ascension As Date, Pentecote As Date
ferie = False
If DateTest = "" Then Exit Function
JJ = Day(DateTest)
MM = Month(DateTest)
AA = Year(DateTest)
If JJ = 1 And MM = 1 Then ferie = True: Exit Function '1 Janvier
If JJ = 1 And MM = 5 Then ferie = True: Exit Function '1 Mai
If JJ = 8 And MM = 5 Then ferie = True: Exit Function '8 Mai
If JJ = 14 And MM = 7 Then ferie = True: Exit Function '14 Juillet
If JJ = 15 And MM = 8 Then ferie = True: Exit Function '15 Août
If JJ = 1 And MM = 11 Then ferie = True: Exit Function '1 Novembre
If JJ = 11 And MM = 11 Then ferie = True: Exit Function '11 Novembre
If JJ = 25 And MM = 12 Then ferie = True: Exit Function '25 Décembre
NbOr = (AA Mod 19) + 1
Epacte = (11 * NbOr - (3 + Int((2 + Int(AA / 100)) * 3 / 7))) Mod 30
PLune = DateAdd("d", CDate("19/04/" & AA), -((Epacte + 6) Mod 30))
If Epacte = 24 Then PLune = DateAdd("d", PLune, -1)
If Epacte = 25 And (AA >= 1900 And AA < 2000) Then PLune = DateAdd("d", PLune, -1)
Paques = DateAdd("d", PLune, 7 - Weekday(PLune) + vbMonday) 'Paques
If JJ = Day(Paques) And MM = Month(Paques) Then ferie = True: Exit Function
Ascension = DateAdd("d", Paques, 38) 'Ascension
If JJ = Day(Ascension) And MM = Month(Ascension) Then ferie = True: Exit Function
Pentecote = DateAdd("d", Ascension, 11) 'Pentecote
If JJ = Day(Pentecote) And MM = Month(Pentecote) Then ferie = True: Exit Function
End Function
Public Function NbHeures(ByVal Priorite As String, ByVal dte1 As Date, ByVal dte2 As Date) As Integer
Dim nbs As Integer, nbjr As Integer, nbhr As Integer
Dim i As Integer, NbJrFerie As Integer
If Priorite = "p1" Then
For i = 0 To DateDiff("d", dte1, dte2)
If ferie(DateAdd("d", dte1, i)) And Weekday(DateAdd("d", dte1, i), vbSunday) > 1 Then NbJrFerie = NbJrFerie + 1
Next i
nbjr = DateDiff("d", dte1, dte2, vbSunday, vbFirstJan1)
nbs = DateDiff("ww", dte1, dte2, vbSunday, vbFirstJan1)
NbHeures = (nbjr - nbs + 1 - NbJrFerie) * 24
ElseIf Priorite = "p2" Then
For i = 0 To DateDiff("d", dte1, dte2)
If ferie(DateAdd("d", dte1, i)) And Weekday(DateAdd("d", dte1, i), vbSaturday) > 2 Then NbJrFerie = NbJrFerie + 1
Next i
nbjr = DateDiff("d", dte1, dte2, vbSaturday, vbFirstJan1)
nbs = DateDiff("ww", dte1, dte2, vbSaturday, vbFirstJan1)
If Weekday(dte2, vbSaturday) = 1 Then
NbHeures = (nbjr - 2 * nbs + 2 - NbJrFerie) * 8
Else
NbHeures = (nbjr - 2 * nbs + 1 - NbJrFerie) * 8
End If
End If
End Function |
Partager