home *** CD-ROM | disk | FTP | other *** search
/ RBBS in a Box Volume 1 #3.1 / RBBSIABOX31.cdr / ddut / dater.prg < prev    next >
Text File  |  1979-12-31  |  3KB  |  92 lines

  1. * Program...: DATER.CMD
  2. * Author(s).: "UNKNOWN", modified by Luis A. Castro.
  3. * Date......: 1/12/83. 
  4. * Notice....: Copyright 1983, ASHTON-TATE 
  5. * Notes.....: Demonstrates converting from calendar date
  6. *   to julian date, adding a given number of days, then 
  7. *   converting back to the calendar date.
  8.  
  9. SET TALK OFF 
  10. SET BELL OFF 
  11. SET INTENSITY OFF 
  12. ERASE
  13. @ 2, 0 SAY "C A L E N D A R - J U L I A N    C O N V E R S I O N"
  14. @ 3, 0 SAY "========================================"
  15. @ 3,40 SAY "========================================"
  16.  
  17. STORE "        " TO mdate
  18. DO WHILE mdate="  "
  19.    STORE "        " TO mdate
  20.    @ 5,0 SAY 'Enter calendar date ';
  21.          GET mdate PICTURE "99/99/99"
  22.    READ
  23.    STORE VAL($(mdate,1,2)) TO month
  24.    STORE VAL($(mdate,4,2)) TO day
  25.    STORE VAL($(mdate,7,2))+1900 TO year
  26.    IF MONTH>12 .OR. MONTH<1 .OR. DAY>31 .OR. DAY<1
  27.       STORE '        ' TO MDATE
  28.       LOOP
  29.    ENDIF
  30.    IF MONTH=2 .AND. YEAR/4.00#INT(YEAR/4.00) .AND. DAY>28
  31.       STORE '        ' TO MDATE
  32.       LOOP
  33.    ENDIF
  34.    IF MONTH=2 .AND. YEAR/4.00=INT(YEAR/4.00) .AND. DAY>29
  35.       STORE '        ' TO MDATE
  36.       LOOP
  37.    ENDIF
  38.    * If you wish to verify the date and the DATESYS
  39.    * command file has been executed, type the following:
  40.    *   POKE 41997,month,day,year
  41.    *   CALL
  42. ENDDO
  43.  
  44. * Convert from CALENDAR to JULIAN...
  45. * What is 395.25???
  46. STORE INT(30.57*month)+INT(365.25*year-395.25)+day TO julian
  47. * Adjust the julian date if leap year...
  48. IF month > 2
  49.    IF INT(year/4) = year/4
  50.       STORE julian-1 TO julian
  51.    ELSE
  52.       STORE julian-2 TO julian
  53.    ENDIF
  54. ENDIF
  55. @ 6, 0 SAY "The julian date is ="
  56. @ 6,20 SAY julian
  57. STORE 0 TO delta
  58. @ 8,0 SAY "Enter interval in days between dates ";
  59.        GET delta PICTURE "999"
  60. READ
  61. STORE julian+delta TO mjulian
  62.  
  63. * Convert from JULIAN to CALENDAR...
  64. STORE INT(mjulian/365.26)+1 TO year
  65. STORE mjulian+INT(395.25-365.25*year) TO day
  66. * Calculate extra day for leap year...
  67. IF INT(year/4)*4 = year
  68.    STORE 1 TO leapday
  69. ELSE
  70.    STORE 2 TO leapday
  71. ENDIF
  72. * Calculate actual number of days...
  73. IF day > (91-leapday)
  74.    STORE day+leapday TO day
  75. ENDIF
  76. * Generate actual month, day, and year...
  77. STORE INT(day/30.57) TO month
  78. STORE day-INT(30.57*month) TO day
  79. IF month > 12
  80.    STORE 1 TO month
  81.    STORE year+1 TO year
  82. ENDIF
  83.  
  84. * Set-up the calendar date and display it...
  85. STORE year-1900 TO year
  86. STORE STR(month,2)+"/"+STR(day,2)+"/"+STR(year,2) TO mdate
  87. @ 10,0 SAY "CALENDAR DATE = "+mdate
  88.  
  89. RELEASE leapday,mdate,julian,mjulian,day,month,year,delta
  90. RETURN 
  91. * EOF dater.cmd
  92.