Information Technology Reference
In-Depth Information
mod .
The line
mod ( date-yyyy , 400)
will be 0 if the variable
date-yyyy
is exactly divisible by 400. If it not, the result of the line will be the remainder of that
division, namely the year divided by 400. Thus a result of 0 means that we have a leap
year and so the variable
leap-switch
is set to ā€œyā€. Initially this field had the value of ā€œnā€ so if we have a positive remainder,
nothing further happens and we don't have a leap year. With that in mind you can now
figure out what
if mod ( date-yyyy (3:2) ,4) = 0
does. To start with it takes the full year but only uses the two rightmost digits and tries to
divide by 4. If there is no remainder, we have a leap year. Otherwise we have an invalid
date. If you suggest that we could have used the full year instead, you're correct and
you're paying attention but we could just divide the last two digits of the year since it
won't matter what the two leftmost digits are. That's all there is to verify a date. I think
you will agree that this is a useful copy member to have.
Search WWH ::




Custom Search