Guidance
指路人
g.yi.org
software / rapidq / Examples / Date & Time / Qcalendar / objDate.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'-----------------------------------------------------------
'Any comment here : victor.garnier@ifrance.com
'Made on 03/10/2002 00:49
'Revision on 03/10/2002 23:55
'----------------------------------------------------------
'----
     DEFSTR MonthName(12) = {"Janvier", "Février", "Mars"," Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Décembre"}
'dayname(0) = Dimanche
     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

'IsLeapYear
     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
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2024-11-28  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-10-04 15:37:24