Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Leap years
Message
 
To
07/07/1998 20:28:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00115008
Message ID:
00115100
Views:
15
>Hi Jim,
>Fox knows which years are leap years...
>FUNCTION LeapYear
>LPARAMETER nYear
>RETURN CTOD("29/2/" + LTRIM(STR(m.nYear))) <> {}
David,

You're right that fox knows the leap years. However, as often happens you assumed that all users will have the same SET DATE in effect that you use. You're code revised to handle the set dates would be;
FUNCTION LeapYear
LOCAL lcDate, llRet
lcDate = SET("DATE")
SET DATE AMERICAN
LPARAMETER nYear
llRet = NOT EMPTY(CTOD("2/29/" + LTRIM(STR(m.nYear))))
SET DATE &lcDate
RETURN llRet
We can't always assume that the date setting at runtime will be the same as we use on our own machines. CTOD() is affected by the set date command.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform