Hi everyone! Yes, I'm the Salty Dog page, and this library is an attempt to replicate what's in C#'s static classes, which are really powerful to have around.
The STRING one is mostly complete but I just got started on the DATETIME and it's definitely a work in progress. To stay on top of it, you can click the "Watch" button on the GitHub page and you'll get notifications whenever a new commit happens (I've done a lot just in the last few days as I've been using this library as I work on another class to validate JWTs in FoxPro. I really like all the feedback! Another thing you can do is submit an issue on the GitHub page itself (and then get notified when it's handled) or better yet, clone the repo and make some contributions! :) Eric On Fri, May 18, 2018 at 1:26 PM, Jürgen Wondzinski <[email protected]> wrote: > This FirstDayOfQuarter and siblings is much easier to do: > > ******************************************* > FUNCTION GoQuarter(dDate, cValue) > * "L" = (L)ast day of dDate's Quarter > * "F" = (F)irst day of dDate's Quarter > * "N" = first day of (n)ext dDate's Quarter > * "P" = first day of (p)previous dDate's Quarter > ******************************************* > > cValue = EVL(cValue, "F") > LOCAL dResult > DO CASE > CASE cValue = "L" > dResult = GOMONTH(dDate,(CEILING(MONTH( > dDate)/3)*3)-MONTH(dDate)+1)-DAY(dDate) > CASE cValue = "F" > dResult = GOMONTH(dDate,(CEILING(MONTH( > dDate)/3)*3)-MONTH(dDate)-2)-DAY(dDate)+1 > CASE cValue = "N" > dResult = GOMONTH(dDate,(CEILING(MONTH( > dDate)/3)*3)-MONTH(dDate)+1)-DAY(dDate)+1 > CASE cValue = "P" > dResult = GOMONTH(dDate,(CEILING(MONTH( > dDate)/3)*3)-MONTH(dDate)-5)-DAY(dDate)+1 > ENDCASE > RETURN dResult > > wOOdy > > > "*´¨) > ¸.·´¸.·*´¨) ¸.·*¨) > (¸.·´. (¸.·` * > .·`.Visual FoxPro: It's magic ! > (¸.·``··* > > > > > -----Ursprüngliche Nachricht----- > Von: ProFox <[email protected]> Im Auftrag von Frank Cazabon > Gesendet: Freitag, 18. Mai 2018 18:41 > An: [email protected] > Betreff: Re: Fun with date calculations in VFP > > Lots of spare time today so some hopefully constructive criticism: :) > > I would redo some of that code to get away from CTOD() as that will fail > depending on SET STRICTDATE and if SET DATE is anything besides MDY. > > I have a feeling that your first day of week and last day of week will > be incorrect in situations with SET FDOW. > > I think PARAMETERS() is also advised against and PCOUNT() is better. > > I would also move each function into its own program. > > For example FirstDayOfQuarter.prg would be: > > LPARAMETERS tdDate > > LOCAL lnMonth as Integer, lnYear as Integer, ldDate as Date > if PCOUNT()=0 then > m.tdDate = date() > endif > m.lnYear = YEAR(m.tdDate) > m.lnMonth = MONTH(m.tdDate) > DO CASE > CASE BETWEEN(m.lnMonth,1,3) > m.ldDate = DATE(m.lnYear, 1, 1) > CASE BETWEEN(m.lnMonth,4,6) > m.ldDate = DATE(m.lnYear, 4, 1) > CASE BETWEEN(m.lnMonth,7,9) > m.ldDate = DATE(m.lnYear, 7, 1) > OTHERWISE && CASE BETWEEN(m.lnMonth,10,12) > m.ldDate = DATE(m.lnYear, 10, 1) > ENDCASE > return ldDate > > > Frank. > > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/CAAwxvUm-Mj+cv4v+aW=8q+pxsdzzlkjtk7fxaxcwm-qz4ek...@mail.gmail.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

