Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Leap years
Message
 
À
07/07/1998 20:28:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00115008
Message ID:
00115100
Vues:
16
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform