X-title:  Фунция Calendar (Clipper 5.0)
X-author: Rod Cushman
X-file: calend.zip

  Function Calendar( dStartDate, nTRow, nLCol, cColorStr)
  Version: 2.1


  By:   Rod Cushman
	4773 S. Breton Ct. S.E.  #213
	Kentwood, MI  49508
		(616) 554-9563

        CIS #: 71212,1243

        July 27, 1993

<<=====================================================================>>
<< NOTE:                                                               >>
<<      The Calendar function was derived from a program submitted by: >>
<<      JP Steffen                      Compuserve: 76525,262          >>
<<      Leadership Data Services        Telephone:  515-266-0975       >>
<<      725 Grandview                                                  >>
<<      Des Moines, Iowa 50316                                         >>
<<                                                                     >>
<<      December 31, 1990                                              >>
<<                                                                     >>
<<      I have made several major changes to the source code; but I    >>
<<      would like to thank Mr. Steffen for his original work; it      >>
<<      provided a nice starting point.                                >>
<<                                                                     >>
<< I have contacted JP Steffen regarding any legality w/regards to     >>
<< program; with full clearance.                                       >>
<<                                                                     >>
<< The following text was originally supplied with the Calendar        >>
<< function.                                                           >>
<<                                                                     >>
> Perhaps you have been struggling like I have, trying to               <
> learn all the great new features in Clipper 5.0.  Well, I decided to  <
> create this calendar function as a good way jump in to the language   <
> enhancements.                                                         <
>                                                                       <
> This function allows you to pop-up a monthly calendar, roll to a new  <
> month or year, using ENTER to select an output date. You should be    <
> able to build a scheduling system using this function.                <
>                                                                       <
>                                                                      <
>       Moves Cursor to a new date                                    <
>                                                                      <
>                                                                       <
>    Page-Up         Calendar for 30 days ago                           <
>    Page-Down       Calendar 30 days hence                             <
>    Cntr-Page-Up    Calendar for 365 days ago                          <
>    Cntr-Page-Down  Calendar 365 days hence                            <
>                                                                       <
> The color and screen location is configured by parameter passing.     <
>                                                                       <
> Your encouraged to modify and improve this code.  Please contact me   <
> (76525,262) with your comments & suggestions.                         <
>                                                                       <
> If you configured Clipper 5.0 according to Nantucket's installation   <
> the CLIPCAL.BAT file should compile & link the program TEST_CAL.PRG.  <
> Or you can compile calendar.prg as a standalone with the /n parameter.<
>                                                                       <
>                               Happy New Year!                         <
>                               JP Steffen                              <
>                               Leadership Data Services                <
<<=====================================================================>>

I have since modified the functionality of Mr. Steffen's program
according to the following:

 1)     The original program painted a rather large calendar on the
        screen; I have since shrunk the size of this box so that it does
        not cover so much acreage.

 2)     The original code did not do any parameter verification;
        parameters now default to the
                dStartDate  :  Current Date()
                nTRow       :  MaxRow() -  7
                nLCol       :  MaxCol() - 23
                cColorStr   :  current color

 3)     Function saves and restores current background screen, color,
        and Scoreboard status.

 4)     Function allows the user to select any year from 0100 ad to
        2199 ad.  This is either via the cursor, PgUp or PgDn, or the
        Alt-Y (Get Year) keys.  Upon return from the Alt-Y pop-up box,
        the calendar displays the current month and date for the
        selected year.  Function will detect when the window is out of
        display coordinates and automatically adjust the window back within
        constraints (via calls to MaxRow(), MaxCol()).

 5)     Function allows the user to select any month via the Alt-M (Get
        Month) key.  The function defaults to the current month
        selected.  Upon month selection the calendar displays the
        selected month.  Function will detect when the window is out of
        display coordinates and automatically adjust the window back within
        constraints (via calls to MaxRow(), MaxCol()).  If the date
        adjustment is not within the month's maximum days, the date will be
        reset to the first of the given month.

 6)     Improved functionality of MoveMonth() function; original code
        added/subtracted 30 days from the current date.  Now the
        function takes into account the length of the month.  In most
        cases, the user is displayed the same day of the month when
        scrolling through dates via the Alt-M, Alt-Y, Ctrl-PgUp,
        Ctrl-PgDn, and PgUp, PgDn keys.

 7)     Modified functionality of Home, End keys.  Prior version of program
        used the Home and End keys to scroll diagonally, regardless of
        diagonal value. Current version now uses the Home (K_HOME) to
        revert to the first day of the current month.  The End (K_END) key
        progresses to the last day of the current month.

 8)     I have revised the sample program called Test_Cal.prg which
        displays the calendar in the user selected color and position.
        Also, a view of the source code will show a sample usage of the
        calendar for @ x,y Get <var> Valid Calendar(...).  The sample
        program testtime() was written for a friend who needed the ending
        date of the date range to be greater than or equal to the beginning
        date.  The validation logic of testtime.prg reflects this option.

 9)     I have included new function key definitions: Ctrl-Home goes to
        first day of the current year. Ctrl-End goes to the last day of the
        current year.  Home goes to the first day of the current month.
        End goes to the last day of the current month.

10)     The new set of valid key exceptions for the calendar program are
        the following:

                        
                          Moves Cursor to a new date
                        

                       Page-Up         Calendar for previous month
                       Page-Down       Calendar for succeeding month
                       Ctrl-Page-Up    Calendar for 365 days ago
                       Ctrl-Page-Down  Calendar 365 days hence
                       Alt-M           Pop-up month selector
                       Alt-Y           Pop-up year selector (0100 - 2199)
                       Home            Revert to first day of current month
                       End             Go to last day of the current month
                       Ctrl-Home       Revert to first day of current year
                       Ctrl-End        Go to last day of the current year
                       Esc             Return original value passed to the
                                       calendar function.
                       Space           Return Blank Date ( CtoD(Space(8)) )

11)     I have included sample programs for usage of the calendar program.
        They are meant as examples; hope they help.  The names of the test
        programs are: TEST_CAL.PRG, TEST_TIME.PRG and TEST_DATE.PRG.  All
        three use the calendar function for date validation and selection.

12)     DISCLAIMER:  Please feel free to make revisions to the source.  I
        would appreciate any comments or suggestions.  The code has some
        possibility; especially with the use of tbrowse colors for weekends,
        holidays, etc.  The code is provided 'AS-IS' with no guarantees or
        warranties.

13)     I have fixed an anomally with the Calendar function with regards to
        advancing past 12/31/1999.  Version 2.0 would revert back to Feb 1,
        1900 when advancing into the year 2000.  I removed code involving the
        EPOCH and cleaned up other code.  Also, I reverted back to the
        current date when the user attempts to go beyond the date limits of
        Clipper (01/01/0100 and 12/31/2999).  Version 2.0 allowed for a
        subseqeunt (illegal) month; returning an empty date to the user.
        Both anomallies have been fixed.

Revision History:
        April 19, 1992  Rod     Submitted onto CompuServe original version.
        May 25, 1993    Rod     Fixed anomally with the 'Alt-M' function;
                                now checks validity of new date.
        June 10, 1993   Rod     Fixed anomally with the Page-Up, Page-Down
                                commands; keys will now skip to same day (if
                                possible) on the prior/next month.
        June 10, 1993   Rod     Revised documentation and uploaded onto
                                PD/Shareware.
        July 27, 1993   Rod     Fixed anomally with year 2000; fixed
                                anomally with 01/01/0100 (min date) and
                                12/31/2999 (max date).
