Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any function for check if its a leap year ?
Message
 
To
24/02/2003 20:16:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00756383
Message ID:
00757379
Views:
14
>
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform