J'ai codé ce matin une petite fonction dont j'avais besoin pour mon boulot : vu qu'elle n'a pas l'air de trop mal fonctionner, je partage

Il s'agit d'une fonction qui permet de donner la date du xxxème jour d'une année donnée. Par exemple,
_YDay_To_Date("90", "2015") nous donnera "2015/03/31", soit aujour'hui, qui se trouve être ... le 90ème jour de 2015

N'hésitez pas à corriger mes erreurs, je suis preneur.
Code : Tout sélectionner
#include <Date.au3>
MsgBox(0,"",_YDay_To_Date("90", "2015"))
; #FUNCTION# ====================================================================================================================
; Name ..........: YDay_To_Date
; Description ...: Give the date of the xxxth day of a given year
; Syntax ........: YDay_To_Date($yday, $year)
; Parameters ....: $yday : the day number you want to "convert" to date
; : $year : the concerned year
; Return values .: If there's no error, the date in standard format (YYYY/MM/DD) ; otherwise, nothing.
; Author ........: GhostLine
; Example .......: Yes
; ===============================================================================================================================
Func _YDay_To_Date($yday, $year)
If _DateIsLeapYear($year) And $yday > 364 Or $yday > 365 Then Exit
$month = 1
For $day = 1 To $yday
If $day = $yday Then ExitLoop
If _DateIsValid($year & "/" & StringRight(0 & $month, 2) & "/" & StringRight(0 & $day, 2)) <> 1 Then
$yday = $yday - ($day - 1)
$day = 1
$month = $month + 1
EndIf
Next
Return($year & "/" & StringRight(0 & $month, 2) & "/" & StringRight(0 & $yday, 2))
EndFunc ;==>_YDay_To_Date