DEFSTR MonthName(12) = {"Janvier", "Février", "Mars"," Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Décembre"}
DEFSTR DayName(6) = {"Dimanche","Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"}
DECLARE FUNCTION IsAnneeBissextile(intYear AS INTEGER) AS INTEGER
DECLARE FUNCTION GetNbDaysInMonth(BYVAL intMonth AS INTEGER, BYVAL intYear AS INTEGER) AS INTEGER
DECLARE FUNCTION IsDateValid(stringDate AS STRING) AS INTEGER
DECLARE FUNCTION GetLongDate(dtDate AS STRING, blnRealLong AS INTEGER) AS STRING
DECLARE FUNCTION DayOfWeek(y1 AS LONG, m1 AS INTEGER, d1 AS INTEGER) AS INTEGER
FUNCTION DayOfWeek(y1 AS LONG, m1 AS INTEGER, d1 AS INTEGER) AS INTEGER
DEFINT lm, ly, iResult
lm = m1 : ly = y1
IF lm < 3 THEN
ly = ly - 1
lm = lm + 12
END IF
iResult = (d1 + (153 * lm - 457) \ 5 + INT(365.25 * ly) - INT(ly * .01) + INT(ly * .0025) + 2) MOD 7
DayOfWeek = IIF(iResult<0,iResult = iResult + 7,iResult)
END FUNCTION
FUNCTION IsAnneeBissextile(intYear AS INTEGER) AS INTEGER
IsAnneeBissextile = ((intYear MOD 4 = 0) AND (intYear MOD 100 <> 0)) OR (intYear MOD 400 = 0)
END FUNCTION
FUNCTION GetNbDaysInMonth(intMonth AS INTEGER,intYear AS INTEGER) AS INTEGER
SELECT CASE intMonth
CASE 2 : GetNbDaysInMonth = IIF(IsAnneeBissextile(intYear) = -1,29,28)
CASE 4, 6, 9, 11 : GetNbDaysInMonth = 30
CASE ELSE : GetNbDaysInMonth = 31
END SELECT
END FUNCTION
FUNCTION IsDateValid(stringDate AS STRING) AS INTEGER
DEFINT intDay, intMonth, intYear
IF LEN(stringDate) <> 10 THEN IsDateValid = False : EXIT FUNCTION
intDay = VAL(MID$(stringDate,1,2))
intMonth = VAL(MID$(stringDate,4,2))
intYear = VAL(RIGHT$(StringDate, 4))
IF intMonth > 31 THEN isDateValid = False : EXIT FUNCTION
IF intDay > GetNbDaysInMonth(intMonth, intYear) THEN IsDateValid = False : EXIT FUNCTION
IsDateValid = True
END FUNCTION
FUNCTION GetLongDate(dtDate AS STRING, blnRealLong AS INTEGER) AS STRING
DEFINT intDay, intMonth, intYear, iFirstDay
intDay = VAL(MID$(dtDate,1,2))
intMonth = VAL(MID$(dtDate,4,2))
intYear = VAL(RIGHT$(dtDate, 4))
iFirstDay = DayOfWeek(intyear,intmonth,intday)
IF blnRealLong THEN
GetLongDate = DayName(iFirstDay) + " " + STR$(intDay) + " " + MonthName(intMonth-1) + " " + STR$(intYear)
ELSE
GetLongDate = MonthName(intMonth-1) + " " + STR$(intYear)
END IF
END FUNCTION
|