home *** CD-ROM | disk | FTP | other *** search
/ Software Du Jour / SoftwareDuJour.iso / BUSINESS / DBASE / DBAPG.ARC / WEEKDAY.PRG < prev   
Encoding:
Text File  |  1984-08-12  |  1.6 KB  |  44 lines

  1. * Program.: WEEKDAY.PRG
  2. * Author..: Bob Simpson, modified by Luis A. Castro
  3. * Date....: 8/6/83, 11/20/83, 01/19/84
  4. * Notice..: Copyright 1983 & 1984, Bob Simpson, All Rights Reserved
  5. * Version.: dBASE II, version 2.4x
  6. ¬ Notes...: Gets the day of the week from a calendar date.
  7. * Local...: t:date, t:month, t:day, t:century, t:yrcount
  8. *
  9. *    IN:    mdate-C-8     Calendar date, assumed to be in 
  10. *                         MM/DD/YY format, and a valid date.
  11. *
  12. *   OUT: week:num-N-1     Day of the week number value
  13. *        week:day-C-9     Day of the week character value
  14. *
  15. STORE mdate TO t:date
  16. * ---Format of MM/DD/YY will get MM/DD/YYYY for 20th century.
  17. STORE $( t:date, 1, 5 ) + "/" +;
  18.       STR( VAL( $( t:date, 7, 2 ) ) + 1900, 4 ) TO t:date
  19. *
  20. * ---Segments of julian date conversion code follows.
  21. STORE VAL($(t:date,1,2)) TO t:month
  22. STORE VAL($(t:date,4,2)) TO t:day
  23. STORE VAL($(t:date,9,2)) TO t:yrcount
  24. STORE 19 TO t:century
  25. IF t:month > 2
  26.    STORE t:month - 2 TO t:month
  27. ELSE
  28.    STORE t:month + 10 TO t:month
  29.    STORE t:yrcount - 1 TO t:yrcount
  30. ENDIF
  31. *
  32. * ---Reverend Zeller Theorem.
  33. STORE INT( ( 13 * t:month - 1 ) / 5 ) + t:day + t:yrcount +;
  34.       INT( t:yrcount / 4 ) + INT( t:century / 4 ) -;
  35.       2 * t:century TO week:num
  36. STORE INT( week:num - 7 * INT( week:num / 7 ) ) + 1 TO week:num
  37. STORE TRIM( $( "SUNDAY   MONDAY   TUESDAY  WEDNESDAY" +;
  38.                "THURSDAY FRIDAY   SATURDAY ",;
  39.       ( week:num - 1 ) * 9 + 1, 9 ) ) TO week:day
  40. *
  41. RELEASE t:date, t:month, t:day, t:century, t:yrcount
  42. RETURN 
  43. * EOF: WEEKDAY.PRG
  44.