Current area: HOME ->

Zip File view

The TSR unit will take your Turbo Pascal 5.5 application and


This page allows you to view the contents of a file contained inside a ZIP archive available at Programmer's Heaven. This means you can view the code and find what you need from it without having to download the ZIP file first. If the file contains source code for a language we recognize, we have syntax highlighted it.

Filename displayed: CALENDAR.PAS
Found in file: TPTSR.ZIP

Download: 3D Tutorial v1.8 in Turbo pascal
{

    calendar.pas
    1-19-1990

    Copyright 1990
    John W. Small
    All rights reserved

    PSW / Power SoftWare
    P.O. Box 10072
    McLean, Virginia 22102 8072


    The Gregorian calendar is valid for September 15, 1752
    to the present.  It is based on a 400 year cycle with
        every fourth year a leap year unless divisible by 100.
        Years divisible by 400 are also leap years.  There are
        then 100 - 4 + 1 = 97 leap days in 400 years.  97 +
        400 * 365 = 146097 days.  Thus the number of days in
        400 years is evenly divisible by seven.

    The Julian date is the number of the days starting
    from year 1 A.D.

}


unit calendar;

interface

        uses crt;

        const

                DaysInMonth : array[1..12] of integer = (
                        31,28,31,30,31,30,31,31,30,31,30,31
                );

                months : array[1..12] of string[9] = (
                        'January', 'February', 'March',
                        'April', 'May', 'June',
                        'July', 'August', 'September',
                        'October', 'November', 'December'
                );

                days : array[1..7] of string[9] = (
                        'Sunday', 'Monday','Tuesday', 'Wednesday',
                        'Thursday', 'Friday', 'Saturday'
                );

                function  DayOfTheWeek(year,month,day : integer):integer;
                function  LeapYear(year : integer) : boolean;
                function  DayOfTheYear(year,month,day : integer):integer;
                procedure CalendarRC(year, month, day : integer;
                                        var r, c : byte);
                procedure WriteCalendar(year, month : integer);


implementation

        function  DayOfTheWeek(year,month,day : integer):integer;
                var y,c,m,d : integer;
                begin
                        { Zeller's congruence }
                        dec(month,2);
                        if month <= 0 then begin
                                inc(month,12);
                                dec(year)
                                end;
                        y := year mod 100;
                        c := year div 100;
                        d :=  (26 * month - 2) div 10 +
                                day + y + y div 4 + c div 4 - 2 * c;
                        while (d < 0) do
                                inc(d,7);
                        DayOfTheWeek := d mod 7 + 1
                end;

        function  LeapYear(year : integer) : boolean;
                begin
                        if not boolean(year mod 4) and
                                boolean(year mod 100) or
                                not boolean(year mod 400)
                                then LeapYear := true
                                else LeapYear := false
                end;

        function  DayOfTheYear(year,month,day : integer):integer;
                var m, d : integer;
                begin
                        d := 0;
                        for m := 1 to month - 1 do
                                inc(d,DaysInMonth[m]);
                        if (not boolean(year mod 4) and
                                boolean(year mod 100) or
                                not boolean(year mod 400)) and
                                (month > 2) then
                                inc(d);
                        DayOfTheYear := d + day
                end;

        procedure CalendarRC(year, month, day : integer;
                                var r, c : byte);
                var firstOfs :  integer;
                begin
                        firstOfs := DayOfTheWeek(year,month,1) - 1;
                        r := (day - 1 + firstOfs) div 7 + 1;
                        c := (day - 1 + firstOfs) mod 7 + 1
                end;

        procedure WriteCalendar(year, month : integer);
                const  WeekDays = '  S  M Tu  W Th  F  S ';
                var x, y, r, c : byte;
                        day : integer;
                begin
                        x := wherex; y := wherey;
                        write('   ',months[month],'  ',year);
                        inc(y);
                        gotoxy(x,y);
                        write(WeekDays);
                        for day := 1 to DaysInMonth[month] do begin
                                CalendarRC(year,month,day,r,c);
                                gotoxy((c-1)*3+x,r+y);
                                write(day:3);
                                end;

                end;

        begin
        end.


Convert TIFF files to GROB files, DOS Program

S3 FRAC.OPA - Hop-a-long style programm.

3D Tutorial v1.8 in Turbo pascal

Download Convert TIFF files to GROB files, DOS Program Download S3 FRAC.OPA - Hop-a-long style programm. Download 3D Tutorial v1.8 in Turbo pascal







Sponsored links

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Localize software in three simple steps
Localize .Net, C/C++ & Delphi apps visually. HTML, HTML Help, XML & databases. Try Sisulizer now!
Localize Delphi software in three simple steps
Localize Delphi VCL & .Net apps visually. Plus HTML, HTML Help, XML & databases. Try Sisulizer now!
Web based bug tracking - AdminiTrack.com
AdminiTrack offers an effective web-based bug tracking system designed for professional software development teams.


Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Synchron Data - .NET development.