home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / calculat / julian.lbr / JULIAN.CQD / JULIAN.CMD
OS/2 REXX Batch file  |  1987-01-31  |  3KB  |  89 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. *--------------------------------------------------------------
  18. * The 1984 World Almanac, which tells us that the Julian period
  19. * was devised in 1582 by Joseph Schliger and named after his
  20. * father Julius, not after Julius Caesar or the Julian calendar.
  21. * Scaliger began the first Julian Day (JD) at noon, January 1,
  22. * 4713 B.C., the most recent time that three major chronological
  23. * cycles began on the same day: the 28-year solar cycle, the
  24. * 19-year lunar cycle, and the 15-year indication cycle.  It will
  25. * take to the year 3267 to complete the period, a total of 7980
  26. * years which is the product of 28,19, and 15.  This algorithm is
  27. * accurate from 1/1/0000 to 12/31/3999 due to a problem with
  28. * negative numbers.  MDATE must be previously verified through
  29. * the system date.  When using the system date 1900 or greater
  30. * is assumed.
  31. * MDATE = MM/DD/YYYY
  32. * ASSUME 1900 OR GREATER FOR USE OF SYSTEM DATE.
  33.  
  34. STORE $(DATE(),1,6)+'19'+$(DATE(),7,2) TO MDATE
  35. STORE VAL($(MDATE,1,2)) TO MM
  36. IF MM <= 00 .OR.  MM > 12
  37.    STORE 'MONTH ERROR' TO TODAY
  38.    STORE 'MONTH ERROR' TO BIG:DAY
  39.    RELEASE MDATE,MM
  40.    RETURN
  41. ENDIF
  42. STORE VAL($(MDATE,4,2)) TO DD
  43. IF DD <= 00 .OR. DD > 31
  44.    STORE 'DAY ERROR' TO TODAY
  45.    STORE 'DAY ERROR' TO BIG:DAY
  46.    RELEASE MDATE,MM,DD
  47.    RETURN
  48. ENDIF
  49. STORE VAL($(MDATE,7,4)) TO YR
  50. STORE 1721060 TO BASE
  51. * -----  CALC JULIAN HERE -------------------------------------
  52. STORE BASE + YR*365 + INT(YR/4) - INT(YR/100) + INT(YR/400)+;
  53.   VAL($('000031059090120151181212243273301334',MM*3-2,3))+;
  54.   DD-VAL($('110000000000',MM,1)) *;
  55.   VAL($('10',1+INT(((YR/4)-INT(YR/4))+.75)*;
  56.   INT(((YR/400)-INT(YR/400))+.9975),1)) TO JD
  57.  
  58. * ----- CALC NAME OF DAY HERE ---------------------------------
  59. STORE $('Monday   Tuesday  Wednesday'+;
  60.   'Thursday Friday   Saturday Sunday   ',;
  61.   (int(int((((JD/7.00)-INT(JD/7))*7)+.5))*9+1),9) TO TODAY
  62.  
  63. * ----- CALC NAME OF MONTH HERE -------------------------------
  64. STORE $('January  Febuary  March    April    May      '+;
  65.    'June     July     August   SeptemberOctober  November '+;
  66.    'December ',MM*9-8,9) to MONTH
  67.  
  68. * ----- MAKE A GOOD PRINT DATE FROM THE DATA ABOVE ------------
  69. STORE TRIM(TODAY) + ', ' + TRIM(MONTH) + STR(DD,3) + ', ' +;
  70.     STR(YR,5) TO BIG:DAY
  71.  
  72. * ----- RESTORE THE ENVIRONMENT AND EXIT ----------------------
  73. RELEASE MONTH,DD,YR,MM,MDATE,BASE,JD
  74. RETURN
  75.  
  76. *--------------------------------------------------------------
  77. **********     END   OF   JULIAN.CMD    PROGRAM      **********
  78. *--------------------------------------------------------------
  79. $('000031059090120151181212243273301334',MM*3-2,3))+;
  80.   DD-VAL($('110000000000',MM,1)) *;
  81.   VAL($('10',1+INT(((YR/4)-INT(YR/4))+.75)*;
  82.   INT(((YR/400)-INT(YR/400))+.9975),1)) TO JD
  83.  
  84. * ----- CALC NAME OF DAY HERE ---------------------------------
  85. STORE $('Monday   Tuesday  Wednesday'+;
  86.   'Thursday Friday   Saturday Sunday   ',;
  87.   (int(int((((JD/7.00)-INT(JD/7))*7)+.5))*9+1),9) TO TODAY
  88.  
  89. * ----- CALC NAME OF MONTH HERE ----------------------------