Tech Tip: Utility for checking for leap year
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Mac & Win
Published On: June 27, 2013
Developers may need to verify if a year selected is a leap year or not. Based on the information in the pseudo code from https://en.wikipedia.org/wiki/Leap_year, here is a utility method that will check if the year input is a leap year:
// ---------------------------------------------------- // Method: UTIL_Is_It_Leap_Year // Description // Returns True or False if it is Leap Year // // Parameters // $1 (Longint) - The year being checked // // $0 (Boolean) - True = Leap year ; False = Not Leap Year // // ---------------------------------------------------- C_LONGINT($1;$year_l) C_BOOLEAN($0;$is_it_leap_b) $year_l:=$1 Case of : ($year_l%400=0) $is_it_leap_b:=True : ($year_l%100=0) $is_it_leap_b:=False : ($year_l%4=0) $is_it_leap_b:=True Else $is_it_leap_b:=False End case $0:=$is_it_leap_b |
Below is an example of how the utility method can be used, taking a year as its parameter:
C_BOOLEAN($is_it_leap_b) $is_it_leap_b:=UTIL_Is_It_Leap_Year (2016) |