TURBO PASCAL |
Новости
|
3.What is the code for the weekday of a given date?Q: I want code that gives the weekday of the given date. A1: There is a WKDAYFN function in my Turbo Pascal units collection ftp://garbo.uwasa.fi/pc/ts/tspa3470.zip (or whatever version number is the latest, and where 70 is 40 50 55 60 and 70) Turbo Pascal units collection to give the modern weekday based on Zeller's congruence. Available by anonymous FTP or mail server from garbo.uwasa.fi. Also you can find a more extensive Julian and Gregorian weekday algorithm with source code in Dr.Dobb's Journal, June 1989, p. 148. Furthermore Press & Flannery & al (1986), Numerical Recipes, Cambridge University Press, present a weekday code. The Numerical Recipes codes are available as ftp://garbo.uwasa.fi/pc/turbopas/nrpas13.zip (big, 404k!). A2: Some will recommend the following kludge. Store the current date, change it, and let MS-DOS get you the weekday. Don't use it! It is a bad suggestion. On top of being sloppy programming, there are several snags. The trick works only for years 1980-2079. A crash the program may leave the clock at a wrong date. And even if multitasking is rare, in a multitasking environment havoc may result for the other tasks. And you may have a TSR that requires the correct date, etc. |
(с)Все права защищены По всем интересующим вопросам прошу писать на электронный адрес |