Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any function for check if its a leap year ?
Message
 
À
24/02/2003 20:16:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00756383
Message ID:
00757379
Vues:
22
>
>procedure checkforleap (tdate as date) as boolean
>  * Find february of that year
>  lddate = ctod("02/01"+str(year(tdate)))
>
>  * Find the number of days in Feburary
>  lidays = day(date(year(lddate),month(gomonth(lddate,1)),1)-1)
>
>return lidays = 29
>
>
>You could make it more compact, but I feel it gets too cryptic.

But it's doing some extra steps, which you can remove without making it (IMHO) less readable.

In the first line, if you start by finding March 1st instead of February 1st, you don't need the GOMONTH() in the second line.

Also, why is the first line using slower CTOD() instead of DATE()? Instead of CTOD("02/01/"+STR(YEAR(tdate))), I'd use DATE(YEAR(tddate)),03,01).

As if you wanted my US$.02 ... *g*
Rich Addison, Micro Vane, Inc., Kalamazoo, MI
Relax, don't worry, have a homebrew.
- Charlie Papazian, The New Complete Joy of Home Brewing
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform