home *** CD-ROM | disk | FTP | other *** search
- * Program.: WEEKDAY.PRG
- * Author..: Bob Simpson, modified by Luis A. Castro
- * Date....: 8/6/83, 11/20/83, 01/19/84
- * Notice..: Copyright 1983 & 1984, Bob Simpson, All Rights Reserved
- * Version.: dBASE II, version 2.4x
- ¬ Notes...: Gets the day of the week from a calendar date.
- * Local...: t:date, t:month, t:day, t:century, t:yrcount
- *
- * IN: mdate-C-8 Calendar date, assumed to be in
- * MM/DD/YY format, and a valid date.
- *
- * OUT: week:num-N-1 Day of the week number value
- * week:day-C-9 Day of the week character value
- *
- STORE mdate TO t:date
- * ---Format of MM/DD/YY will get MM/DD/YYYY for 20th century.
- STORE $( t:date, 1, 5 ) + "/" +;
- STR( VAL( $( t:date, 7, 2 ) ) + 1900, 4 ) TO t:date
- *
- * ---Segments of julian date conversion code follows.
- STORE VAL($(t:date,1,2)) TO t:month
- STORE VAL($(t:date,4,2)) TO t:day
- STORE VAL($(t:date,9,2)) TO t:yrcount
- STORE 19 TO t:century
- IF t:month > 2
- STORE t:month - 2 TO t:month
- ELSE
- STORE t:month + 10 TO t:month
- STORE t:yrcount - 1 TO t:yrcount
- ENDIF
- *
- * ---Reverend Zeller Theorem.
- STORE INT( ( 13 * t:month - 1 ) / 5 ) + t:day + t:yrcount +;
- INT( t:yrcount / 4 ) + INT( t:century / 4 ) -;
- 2 * t:century TO week:num
- STORE INT( week:num - 7 * INT( week:num / 7 ) ) + 1 TO week:num
- STORE TRIM( $( "SUNDAY MONDAY TUESDAY WEDNESDAY" +;
- "THURSDAY FRIDAY SATURDAY ",;
- ( week:num - 1 ) * 9 + 1, 9 ) ) TO week:day
- *
- RELEASE t:date, t:month, t:day, t:century, t:yrcount
- RETURN
- * EOF: WEEKDAY.PRG