DATE CALCULATIONS

 BBS: Inland Empire Archive
Date: 06-20-92 (17:33)             Number: 1043
From: DOUGLAS LUSHER               Refer#: NONE
  To: DOUGLAS LUSHER                Recvd: NO  
Subj: DATE CALCULATIONS              Conf: (2) Quik_Bas
 'continued from previous message
 'here are the last of the date manipulation functions:

 FUNCTION DOW% (DateString$) STATIC
 'returns a value representing the day of the week (0 = Sunday, 1 = Monday,
 'etc) for the date string supplied in the form "MM-DD-YYYY"

 STATIC Month%, Day%, Year%, Temp&
 SHARED Days%()

 Month% = VAL(LEFT$(DateString$, 2))
 Day% = VAL(MID$(DateString$, 4, 2))
 Year% = VAL(RIGHT$(DateString$, 4)) - 1

 'calculate the number of days in all the preceeding years
 Temp& = (Year% * 365&) + (Year% \ 4) - ((Year% \ 100) - (Year% \ 400))

 'add the number of days in the year to the start of the specified month
 'if it's a leap year and after February, add one more day
 Temp& = Temp& + Days%(Month%) - (LeapYear%(Year% + 1) AND (Month% > 2))

 'add the number of days in the specified month
 Temp& = Temp& + Day%

 DOW% = Temp& MOD 7

 END FUNCTION


 FUNCTION LeapYear% (Year%) STATIC
 'returns True (-1) if the specified year is a leap year
 LeapYear% = (((Year% MOD 4 = 0) AND (Year% MOD 100 <> 0))
OR (Year% MOD 400 = 0))
 END FUNCTION


--- TMail v1.29
 * Origin: TC-AMS MLTBBS 2.2 - Minnetonka, MN (612)-938-4799 (1:282/7)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET