Developer Tools
Downloads
Algorithms
 
News
 
Colors
Tools: RAD Clarion for Windows, version 6.x
 
Age
Library: CHSTD, AgeEx()
DateEnd += 1
if DateBegin > 3 and DateBegin < DateEnd
  Days = day(DateEnd) - day(DateBegin)
  Months = month(DateEnd) - month(DateBegin)
  Years = year(DateEnd) - year(DateBegin)
  if Days < 0
    Days = day(date(month(DateBegin)+1,01,year(DateBegin))-1) + Days
    Months -= 1
  end
  if parMonths < 0
    Years -= 1
    Months = 12 + Months
  end
else
  Years = 0
  Months = 0
  Days = 0
end

DateBegin - (in) begin of period
DateEnd - (in) end of period
Years, Months, Days - (out) age as "years,months,days"

Leap-year (the bissextile)
Library: CHSTD, CheckBissextile()
Variant 1:
if (date(12, 31, Year) - date(1, 1, Year) + 1) = 366
  return true
end
return false

Variant 2:
if month((date(2, 29, Year)) = 2
  return true
end
return false

Year - (in)

Quarter of a year
Library: CHSTD, QuarterOfYear()
Quarter = int(Month/4+0.5)+1

Month - (in) from 1 to 12

First day of period
Library: CHSTD, FirstDay()
Millennium:
Date = date(1, 1, int(Year/1000)*1000)
Century:
Date = date(1, 1, int(Year/100)*100)
Year:
Date = date(1, 1, Year)
Quarter:
Date = date(Quarter*3-2, 1, Year)
Month:
Date = date(Month, 1, Year)

Year, Month - (in)

Last day of period
Library: CHSTD, LastDay()
Millennium:
Date = date(12, 31, int(Year/1000)*1000+999)
Century:
Date = date(12, 31, int(Year/100)*100+99)
Year:
Date = date(12, 31, Year)
Quarter:
Date = date(Quarter*3+1, 1, Year) - 1
Month:
Date = date(Month+1, 1, Year) - 1

Year, Month - (in)

Convert h:m:s.o in Clarion-time
Library: CHSTD, Time()
Time += H * 360000
Time += M * 6000
Time += S * 100
Time += O
if Time > 0 then Time += 1 end

H,M,S,O - (in) hours, minutes, seconds, 100-th split second

Number of weeks in the period
Library: CHSTD, WeekNumer()
DayOfWeek1 = DateBegin % 7
if DayOfWeek1 = 0
  DayOfWeek1 = 7
end
if DayOfWeek1 <> 1
  DateBegin += 7 - DayOfWeek1 + 1
end
DayOfWeek2 = DateEnd % 7
DateEnd -= DayOfWeek2

! Number of full weeks
if DateBegin < DateEnd
  WeekNumer = int((DateEnd - DateBegin+1)/7)
end
! + not full week at beginning of the period
if DayOfWeek1 <> 1
  WeekNumer += 1
end
! + not full week at end of the period
if DayOfWeek2 <> 0
  WeekNumer += 1
end

DateBegin,DateEnd - (in)
DayOfWeek1,DayOfWeek2 - local variables

 
  (c) Sergey Chushkin, 2000-2009
Designer & Programmer