8 |
The LA Fox Developer Newsletter
|
December 1997
|
The Leap Year code from Mike McCarthy in a 1996 newsletter failed on first use in Canada because the date format in use was not taken into account. An enhanced and more robust version is as follows:
FUNCTION lsLeapYear
para m.DateOrYear
Pradip Acharya 102413,125@compuserve.com Enhanced version of Leap Year Code by Mike McCarthy
Example: ? lsLeapYear((I I/29/96})
the currently active date format.
PRIV m.p1, m.temp
if EMPTY( m.DateOrYear)
m.pl
=
DATE() && assume current year
else
m.pl
=
m.DateOrYear
endif
If TYPE(”M.Pl”)
==
“D” && set the year
m.pI
=
YEAR( m.pl) endif
m.pl
=
ALLTRIM( STR( m.pI))
m.temp
=
UPPER( ALLTRIM( SET(”DATE”)))
DO CASE
m.temp
=
m.pl
+
“/02/29”
m.temp
=
“02/29/”
+
m.pl
m.temp
=
“29/02/”
+
m.pl
ENDCASE
RETURN !EMPTY( CTOD( m.temp))
can be (1) any date
**_
(2) any numeric year
if
type(’dateyear’)
=
“D” return !empty(CTOD(”02/29/ “+ALLTRIM(STR(YEAR(dateyear))))) else return !empty(CTOD(”02/29/”+ALLTRIM(STR(dateyear)))) endif
RE: Handling ‘February 29th’ with FoxPro
After reading Leap Year Code Using mm/dd Or dd/mm by Pradip Acharya, I started a concerted effort to create compact- unreadable code. I came up with the following solution for determining leap years:
FUNCTION IsLeap( dDate)
RETURN MONTH( GOMONTH( m.dDate,;
-
MONTH( m.dDate)+2)
-
DAY( m.dDate)+29)
=
2
|
Out and About
(Con’t from page3)
the years and we now have to start compensating for those rising costs by doing a little belt-tightening and stepping back to see how we can make the group run a little more efficiently.
We also have other things “on the burners”, so to speak. And we’ll let you know about them as they happen.
But I’ll tell you what. at $48, it’s one heck of a deal!
On to another subject. I’d like to welcome aboard the Newsletter Article Exchange, that was started a couple of years ago, Russell Campbell from the Atlanta FoxPro Users Group. He contributed one of the articles in this issue, “Greenbar Revisited”. So it got me to thinking just how far can you go to simplify code? I ran across an interesting “point-counterpoint” on the subject of how to handle Leap Year problems in code. Take a look at the adjacent column and give it a try. And let me know if it works. <g>
Thanks to Bill Anderson, here’s three more FoxPro-related Internet places you need to visit:
http://www.microsoft.com/msdn/news/imho/111297.htm
http://www.
microsoft.com/vfoxpro/background/vfpbgrnd.htm http://www.news.com/News/Item/
O%2C4%2CI6307%2C00. html?sas. mall
I usually reserve this part of the “Out and About” column for the wiecu, wacky, and unusual things that go on around us everyday that we might otherwise miss. But I’d like to depart from that.. .at least for this issue <g>.
.
.to wish everyone a happy holiday season. It’s been a real pleasure to have been around all of you and to have been associated with this group. So have a safe and happy holiday. And it’s never to early to start looking forward to the good things that might happen in the new year, like Loretta Sanchez and Bob Dornan making up or the end of the Clinton “love-capades” investigation. (Sorry, I just couldn’t help it
)
Soooooooo. Happy Holidays !!!
|
Page 8
|
8 |