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
| Public Function FDateUs(vDate As Date) As String
FDateUs = "#" & Format(vDate, "mm/dd/yyyy") & "#"
End Function
' Retourne le nombre de jour d'un mois donné, en utilisant Day(), DateSerial et DateAdd()
Public Function DaysInMonth(ByVal nMonth As Integer, ByVal nYear As Integer) As Integer
DaysInMonth = Day(DateAdd("d", -1, DateAdd("m", 1, DateSerial(nYear, nMonth, 1))))
End Function
Function EstFerie(ByVal QuelleDate As Date) As Boolean 'Définit les jours fériés de l'année
Dim anneeDate As Integer
Dim joursFeries(1 To 11) As Date
Dim i As Integer
anneeDate = Year(QuelleDate)
joursFeries(1) = DateSerial(anneeDate, 1, 1) 'le 1 janvier
joursFeries(2) = DateSerial(anneeDate, 5, 1) 'le 1 mai
joursFeries(3) = DateSerial(anneeDate, 5, 8) 'le 8 mai
joursFeries(4) = DateSerial(anneeDate, 7, 14) 'le 14 juillet
joursFeries(5) = DateSerial(anneeDate, 8, 15) 'le 15 août
joursFeries(6) = DateSerial(anneeDate, 11, 1) 'le 1 novembre
joursFeries(7) = DateSerial(anneeDate, 11, 11) 'le 11 nobembre
joursFeries(8) = DateSerial(anneeDate, 12, 25) 'le 25 décembre
joursFeries(9) = fLundiPaques(anneeDate)
joursFeries(10) = joursFeries(9) + 38 ' Ascension = lundi de Paques + 38
joursFeries(11) = joursFeries(9) + 49 ' Lundi Pentecôte = lundi de Paques + 49
For i = 1 To 11
If QuelleDate = joursFeries(i) Then
EstFerie = True
Exit For
End If
Next
End Function
Private Function fLundiPaques(ByVal Iyear As Integer) As Date ' Calcul du jour du lundi de Pâques
Dim L(6) As Long, Lj As Long, Lm As Long
L(1) = Iyear Mod 19: L(2) = Iyear Mod 4: L(3) = Iyear Mod 7
L(4) = (19 * L(1) + 24) Mod 30
L(5) = ((2 * L(2)) + (4 * L(3)) + (6 * L(4)) + 5) Mod 7
L(6) = 22 + L(4) + L(5)
If L(6) > 31 Then
Lj = L(6) - 31
Lm = 4
Else
Lj = L(6)
Lm = 3
End If
' Lundi de Pâques = Paques + 1 jour
fLundiPaques = DateAdd("d", 1, (Lj & "/" & Lm & "/" & Iyear))
End Function |
Partager