Time & date fns for APL*PLUS SE 
Author Message
 Time & date fns for APL*PLUS SE

{del}---- APLASCII version:  1.4 (1995.10.15)
{del}---- Source APL system:  APL*PLUS /PC
{del}---- Workspace:  4 TIME

{del}.    #ALX{<-}'#DM'

{del}.    #CT{<-}1.4210854715202004E{neg}14

{del}.    #ELX{<-}'#DM'

{del}.    #IO{<-}1

{del}.    #LX{<-}''

{del}.    #PP{<-}17

{del}.    #RL{<-}16807

{del}.    #SA{<-}''

{del}.    #SEG{<-}0{rho}0

     {del}A{<-}CAL YM;D;E;M;#IO



[4]   #IO{<-}1
[5]   #ERROR((~(,2){match}{rho}YM){or}0{/=}1{take}0{rho}YM)/'DOMAIN ERROR'
[6]   #ERROR(~YM[2]{epsilon}{iota}12)/'DOMAIN ERROR'
[7]   D{<-} 31 28 31 30 31 30 31 31 30 31 30 31
[8]   D[2]{<-}D[2]+2|+/0= 4 100 400 |YM[1]
[9]   M{<-}YM[2]
[10]  YM{<-}YM+(YM[2]{<=}2){times} {neg}1 12
[11]  A{<-}0
[12]  {execute}(158210<E{<-} 10000 100 {basevalue}YM)/'A{<-}2+({floor}0.25{+
   +}{times}A)-A{<-}{floor}0.01{times}YM[1]'
[13]  A{<-}7|{neg}1522+A+({floor}365.25{times}YM[1]+4716)+{floor}30.6001{+
   +}{times}YM[2]+1
[14]  D{<-}{iota}D[M]
[15]  {execute}(E=158210)/'D{<-}(4{take}D),14{drop}D'
[16]  A{<-}'  S  M  T  W  T  F  S',[1]'7BI3' #FMT 6 7 {rho}42{take}(A{rho}0),D
     {del}

     {del}A{<-}TZ CALDATE T;C;D;E;F;M;#IO





[6]   #IO{<-}1
[7]   {execute}(2=#NC 'TZ')/'T{<-}T-TZ{divide}24'
[8]   F{<-}1|T{<-}T+0.5
[9]   T{<-}{floor}T
[10]  A{<-}T{<-},T
[11]  C{<-}(A{>=}2299161)/{iota}{rho}A
[12]  A[C]{<-}{floor}(A[C]-1867216.25){divide}36524.25
[13]  A[C]{<-}T[C]+1+A[C]-{floor}0.25{times}A[C]
[14]  A{<-}A+1524
[15]  D{<-}{floor}365.25{times}C{<-}{floor}(A-122.1){divide}365.25
[16]  E{<-}{floor}(A-D){divide}30.6001
[17]  M{<-}E-1+12{times}E>13
[18]  A{<-}{transpose}((C-4715+M>2),[0.5]M),[1]A+F-D+{floor}30.6001{times}E
[19]  A{<-}A,{transpose} 24 60 60 1000 {represent}86400000{times}1|A[;3]
[20]  A[;3]{<-}{floor}A[;3]
     {del}

     {del}A{<-}CALDAY T;C;D;E;F;M;#IO




[5]   #IO{<-}1
[6]   F{<-}1|T{<-}T+0.5
[7]   T{<-}{floor}T
[8]   A{<-}T{<-},T
[9]   C{<-}(A{>=}2299161)/{iota}{rho}A
[10]  A[C]{<-}{floor}(A[C]-1867216.25){divide}36524.25
[11]  A[C]{<-}T[C]+1+A[C]-{floor}0.25{times}A[C]
[12]  A{<-}A+1524
[13]  D{<-}{floor}365.25{times}C{<-}{floor}(A-122.1){divide}365.25
[14]  E{<-}{floor}(A-D){divide}30.6001
[15]  M{<-}E-1+12{times}E>13
[16]  A{<-}{transpose}((C-4715+M>2),[0.5]M),[1]A+F-D+{floor}30.6001{times}E
     {del}

     {del}A{<-}CALENDAR Y;B;D;DY;E;M;MN;YM;#IO


[3]   #IO{<-}1
[4]   #ERROR((0{/=}{rho}{rho}Y){or}0{/=}1{take}0{rho}Y)/'DOMAIN ERROR'
[5]   D{<-} 31 28 31 30 31 30 31 31 30 31 30 31
[6]   D[2]{<-}D[2]+2|+/0= 4 100 400 |Y
[7]   MN{<-}' JANUARY FEBRUARY   MARCH    APRIL     MAY     JUNE     JULY   '
[8]   MN{<-} 12 21 {first} 12 {neg}15 {first} 12 9 {rho}MN,' AUGUST  {+
   +}SEPTEMBER OCTOBER NOVEMBER DECEMBER '
[9]   A{<-} 35 71 {rho}' '
[10]  M{<-}1

[12]  LOOP:YM{<-}(Y,M)+(M{<=}2){times} {neg}1 12
[13]  B{<-}0
[14]  {execute}(158210<E{<-} 10000 100 {basevalue}YM)/'B{<-}2+({floor}0.25{+
   +}{times}B)-B{<-}{floor}0.01{times}YM[1]'
[15]  B{<-}7|{neg}1522+B+({floor}365.25{times}YM[1]+4716)+{floor}30.6001{+
   +}{times}YM[2]+1
[16]  DY{<-}{iota}D[M]
[17]  {execute}(E=158210)/'DY{<-}(4{take}DY),14{drop}DY'
[18]  A[(9{times}{floor}(M-1){divide}3)+{iota}8;(25{times}3|2+M)+{iota}21]{+
   +}{<-}MN[M;],[1]'  S  M  T  W  T  F  S',[1]'7BI3' #FMT 6 7 {rho}42{take}({+
   +}B{rho}0),DY
[19]  {->}(13>M{<-}M+1)/LOOP
     {del}

     {del}A{<-}F DATESPELL D;DAY;JD;MON;N;T;#IO









   +}{rightbrace}
[10]  #IO{<-}1
[11]  #ERROR(3{or}.{/=}#NC 2 7 {rho}'CALDATEJULIAN ')/'DATESPELL USES {+
   +}CALDATE AND JULIAN'
[12]  {execute}(2{/=}#NC 'F')/'F{<-}0 0'
[13]  F{<-}2{take},F
[14]  F[1]{<-}16|F[1]
[15]  D{<-}({neg}2{take} 1 1 ,{rho}D){rho}D
[16]  #ERROR(3>N{<-}1{drop}{rho}D)/'LENGTH ERROR'
[17]  MON{<-}'JANUARY  FEBRUARY MARCH    APRIL    MAY      JUNE     JULY    {+
   +} AUGUST   SEPTEMBEROCTOBER  NOVEMBER DECEMBER '
[18]  MON[(MON=' ')/{iota}{rho}MON]{<-}#TCDEL
[19]  MON{<-} 12 9 {rho}MON
[20]  DAY{<-}'SUNDAY   MONDAY   TUESDAY  WEDNESDAYTHURSDAY FRIDAY   SATURDAY '
[21]  DAY[(DAY=' ')/{iota}{rho}DAY]{<-}#TCDEL
[22]  DAY{<-} 7 9 {rho}DAY

[24]  JD{<-}F[2]JULIAN D
[25]  D{<-}0 CALDATE JD

[27]  T{<-}((1{take}{rho}D),0){rho}' '
[28]  {->}(N<4)/dATE
[29]  A{<-}1+12<D[;4]
[30]  {execute}(F[1]<8)/'D[;4]{<-}(12{times}0=D[;4])+D[;4]{<-}12|D[;4]'
[31]  T{<-}'I4,P<:>ZI3,P<:>ZI3,P<.>ZI4' #FMT D[;(N-3){take} 4 5 6 7]
[32]  {execute}(F[1]<8)/'T{<-}((T,'' ''),''AP''[A]),''M'''

[34]  dATE:A{<-}((1{take}{rho}D),0){rho}' '
[35]  {->}(4>F{<-}8|F[1])/dATE2
[36]  A{<-}DAY[1+{floor}7|1.5+JD;]
[37]  {execute}(F{epsilon} 4 5)/'A{<-}0 {neg}6{drop}A'
[38]  {execute}(F{epsilon} 5 7)/'A{<-}A,'','''
[39]  A{<-}A,' '
[40]  dATE2:{->}(d0,d1,d2,d3,d0,d1,d2,d3)[1+8|F]
[41]  d0:A{<-}A,('I2,X1,3A1,X1,ZI4' #FMT(D[;3]; 0 {neg}6 {split}MON[D[;2];];{+
   +}D[;1])),T
[42]  {->}0
[43]  d1:A{<-}A,('3A1,X1,ZI2,<, >,ZI4' #FMT(0 {neg}6 {split}MON[D[;2];];D[; {+
   +}3 1])),T
[44]  {->}0
[45]  d2:A{<-}A,('I2,X1,9A1,X1,ZI4' #FMT(D[;3];MON[D[;2];];D[;1])),T
[46]  {->}0
[47]  d3:A{<-}A,('9A1,X1,ZI2,<, >,ZI4' #FMT(MON[D[;2];];D[; 3 1])),T
     {del}

     {del}A{<-}DAYOFWK D;G;N;#IO



[4]   #IO{<-}1
[5]   D{<-}({neg}2{take} 1 1 ,{rho}D){rho}D
[6]   N{<-}1{take}{rho}D
[7]   G{<-}(D[;2]{<=}2)/{iota}N
[8]   D[G;1]{<-}D[G;1]-1
[9]   D[G;2]{<-}D[G;2]+12
[10]  A{<-}N{rho}0
[11]  G{<-}(15821004< 10000 100 100 {basevalue}{transpose}(N,3){take}D)/{+
   +}{iota}N
[12]  A[G]{<-}2+({floor}0.25{times}A[G])-A[G]{<-}{floor}0.01{times}D[G;1]
[13]  A{<-}1+7|{neg}1523+D[;3]+A+({floor}365.25{times}D[;1]+4716)+{floor}30.{+
   +}6001{times}D[;2]+1
     {del}

{del}.    DESCRIBE{<-}'Workspace TIME by Brian B. McGuinness, 1996{nl}{nl}Th{+
+}is workspace contains functions which perform time and date calculations.{{+
+}nl}Some of these funtions are modelled after functions in the standard APL{+
+}*PLUS{nl}workspace DATES.  But note that the functions in this workspace r{+
+}equire that{nl}all of the digits of the year be given, e.g. 1977 rather th{+
+}an just 77.  Also,{nl}the order of arguments for some functions differs fr{+
+}om that of their{nl}STSC/Manugistics equivalents.  For example, the argume{+
+}nt of DAYOFWK is year,{nl}month, day instead of month, day, year.  This ma{+
+}kes the argument more{nl}consistent with the arguments of other functions.{+
+}{nl}{nl}Functions which take a #TS-style date and time as an argument acce{+
+}pt either a{nl}vector with at least three values (year, month, and day) or{+
+} a matrix in which{nl}each row represents a date and time.{nl}{nl}The time{+
+}s returned by FTIMEREP and FTIMEFMT are given to the nearest{nl}millisecon{+
+}d to be consistent with the STSC/Manugistics versions.  But when{nl}applie{+
+}d to #WSTS these times can differ from the times reported by )LOAD by{nl}a{+
+}s much as a second.  In several test cases the FTIMEREP version provided{n{+
+}l}here agreed with the STSC/Manugistics version.{nl}{nl}Reference: Jean Me{+
+}eus, Astronomical Algorithms, Willmann-Bell, Inc.,{nl}           Richmond,{+
+} VA, 1991.{nl}{nl}Calendars:{nl}{nl}CAL       - Generate a calendar for a {+
+}given year and month.  Due to the{nl}            conversion from the Julia{+
+}n calendar to the Gregorian calendar in{nl}            October 1582, that {+
+}month is rather interesting.  (We don''t try to{nl}            take into a{+
+}ccount the fact that the Gregorian calendar was adopted{nl}            on {+
+}different dates in different countries.){nl}{nl}CALENDAR  - Generate a cal{+
+}endar for a given year.{nl}{nl}Functions for dealing with APL*PLUS file an{+
+}d workspace timestamps:{nl}{nl}FTIMEBASE - Convert #TS-style times to the {+
+}number of microseconds since{nl}            January 1, 1900.{nl}{nl}FTIMEF{+
+}MT  - Convert timestamps given as the number of microseconds since{nl}    {+
+}        January 1, 1900 (e.g. #WSTS) to formatted text.{nl}{nl}FTIMEREP  -{+
+} Convert timestamps given as the number of microseconds since{nl}         {+
+}   January 1, 1900 (e.g. #WSTS) to #TS-style times.{nl}{nl}Other date calc{+
+}ulations:{nl}{nl}DAYOFWK   - Find out what day of the week a given date oc{+
+}curs on: 1 = Sunday,{nl}            2 = Monday, ..., 7 = Saturday.{nl}{nl}{+
+}CALDAY    - Convert numbers of days since January 1, 4713 B.C. to calendar{+
+}{nl}            dates ("undo" JULDAY).{nl}{nl}CALDATE   - Convert Julian d{+
+}ay numbers to #TS-style calendar dates and times{nl}            of the day{+
+} ("undo" JULIAN).{nl}{nl}JULDAY    - Convert calendar dates to the numbers{+
+} of days since January 1,{nl}            4713 B.C.  These numbers may be s{+
+}ubtracted to find the number of{nl}            days between two dates, e.g{+
+}. -/JULDAY 2 3{rho}1996 3 2 1996 2 28.{nl}{nl}JULIAN    - Convert calendar{+
+} dates and times of the day, in #TS style, to{nl}            Julian day nu{+
+}mbers (i.e. the number of days since noon Greenwich{nl}            Mean Ti{+
+}me on January 1, 4713 B.C.).{nl}{nl}LEAPYR    - Return 1 for a leap year o{+
+}r 0 for any other year.{nl}{nl}TIMEBASE  - Convert #TS-style times to the {+
+}number of milliseconds since{nl}            January 1, 1900.{nl}{nl}TIMERE{+
+}P   - Convert timestamps given as the number of milliseconds since{nl}    {+
+}        January 1, 1900 to #TS-style times.{nl}{nl}Formatting dates and ti{+
+}mes for display:{nl}{nl}DATESPELL - Formats a date and time in various way{+
+}s, depending on the left{nl}            argument.  For aesthetic reasons, {+
+}the output may contain some{nl}            nonprinting pad characters (#TC{+
+}DEL).  The optional left argument{nl}            is a format selector (an {+
+}integer from 0 to 15), optionally{nl}            followed by a number of h{+
+}ours to add to the specified date {&} time.{nl}{nl}            The availab{+
+}le formats are:{nl}              0 = 1 JAN 1996           4 = MON 1 JAN 19{+
+}96{nl}              1 = JAN 1, 1996          5 = MON, JAN 1, 1996{nl}     {+
+}         2 = 1 JANUARY 1996       6 = MONDAY 1 JANUARY 1996{nl}           {+
+}   3 = JANUARY 1, 1996      7 = MONDAY, JANUARY 1, 1996{nl}{nl}           {+
+} The default format selector and hour offset are zero.  Add 8 to{nl}      {+
+}      the format selector to represent the time of day in 24-hour form{nl}{+
+}            instead of 12-hour AM or PM form.{nl}{nl}            The right{+
+} argument is a #TS-style vector of at least 3 numbers{nl}            (year{+
+}, month, and day) or a matrix with at least 3 columns, where{nl}          {+
+}  each row represents a separate date and time.{nl}{nl}TFMT and{nl}TIMEFMT{+
+}   - Format #TS-style dates and times.  TFMT formats the year with 4{nl}  {+
+}          digits, while TIMEFMT formats it with 2.'

     {del}A{<-}FTIMEBASE D;G;N;#IO





[6]   #IO{<-}1
[7]   D{<-}{transpose}({neg}2{take} 1 1 ,{rho}D){rho}D
[8]   D{<-}(7,N{<-}1{drop}{rho}D){take}D
[9]   G{<-}(D[2;]{<=}2)/{iota}N
[10]  D[1;G]{<-}D[1;G]-1
[11]  D[2;G]{<-}D[2;G]+12
[12]  A{<-}N{rho}0
[13]  G{<-}(15821004< 10000 100 100 {basevalue}(3,N){take}D)/{iota}N
[14]  A[G]{<-}2+({floor}0.25{times}A[G])-A[G]{<-}{floor}0.01{times}D[1;G]
[15]  A{<-}{neg}2416545+D[3;]+A+({floor}365.25{times}D[1;]+4716)+{floor}30.{+
   +}6001{times}D[2;]+1
[16]  A{<-}1000{times}(24 60 60 1000 {basevalue} 3 0 {split}D)+86400000{+
   +}{times}A
     {del}

     {del}A{<-}FTIMEFMT T;C;D;E;M;#IO





[6]   #IO{<-}1
[7]   T{<-} 0 24 60 60 1000000 {represent},T
[8]   T[5;]{<-}{floor}1E{neg}3{times}T[5;]
[9]   A{<-}{floor}(T[1;]+547804.25){divide}36524.25
[10]  A{<-}T[1;]+2416546+A-{floor}0.25{times}A
[11]  D{<-}{floor}365.25{times}C{<-}{floor}(A-122.1){divide}365.25
[12]  E{<-}{floor}(A-D){divide}30.6001
[13]  M{<-}E-1+12{times}E>13
[14]  A{<-}{transpose}(C-4715+M>2),[1]M,[1](A-D+{floor}30.6001{times}E),[1] {+
   +}1 0 {split}T
[15]  A[;1]{<-}100|A[;1]
[16]  A{<-}'I2,</>,ZI2,</>,ZI2,I4,<:>,ZI2,<:>,ZI2,<.>,ZI3' #FMT A[; 2 3 1 4 {+
   +}5 6 7]
     {del}

     {del}A{<-}FTIMEREP T;C;D;E;M;#IO





[6]   #IO{<-}1
[7]   T{<-} 0 24 60 60 1000000 {represent},T
[8]   T[5;]{<-}{floor}1E{neg}3{times}T[5;]
[9]   A{<-}{floor}(T[1;]+547804.25){divide}36524.25
[10]  A{<-}T[1;]+2416546+A-{floor}0.25{times}A
[11]  D{<-}{floor}365.25{times}C{<-}{floor}(A-122.1){divide}365.25
[12]  E{<-}{floor}(A-D){divide}30.6001
[13]  M{<-}E-1+12{times}E>13
[14]  A{<-}{transpose}(C-4715+M>2),[1]M,[1](A-D+{floor}30.6001{times}E),[1] {+
   +}1 0 {split}T
     {del}

     {del}A{<-}JULDAY D;G;N;#IO



[4]   #IO{<-}1
[5]   D{<-}({neg}2{take} 1 1 ,{rho}D){rho}D
[6]   N{<-}1{take}{rho}D
[7]   G{<-}(D[;2]{<=}2)/{iota}N
[8]   D[G;1]{<-}D[G;1]-1
[9]   D[G;2]{<-}D[G;2]+12
[10]  A{<-}N{rho}0
[11]  G{<-}(15821004< 10000 100 100 {basevalue}{transpose}(N,3){take}D)/{+
   +}{iota}N
[12]  A[G]{<-}2+({floor}0.25{times}A[G])-A[G]{<-}{floor}0.01{times}D[G;1]
[13]  A{<-}{neg}1524.5+D[;3]+A+({floor}365.25{times}D[;1]+4716)+{floor}30.{+
   +}6001{times}D[;2]+1
     {del}

     {del}A{<-}TZ JULIAN D;G;N;#IO




   +}{rightbrace}
[5]   #IO{<-}1
[6]   D{<-}({neg}2{take} 1 1 ,{rho}D){rho}D
[7]   N{<-}1{take}{rho}D
[8]   D{<-}(N,7){take}D
[9]   {execute}(2=#NC 'TZ')/'D[;4]{<-}D[;4]+TZ'
[10]  D[;3]{<-}D[;3]+(24 60 60 1000 {basevalue}{transpose}D[; 4 5 6 7]){+
   +}{divide}86400000
[11]  G{<-}(D[;2]{<=}2)/{iota}N
[12]  D[G;1]{<-}D[G;1]-1
[13]  D[G;2]{<-}D[G;2]+12
[14]  A{<-}N{rho}0
[15]  G{<-}(15821004< 10000 100 100 {basevalue}{transpose}D[; 1 2 3])/{iota}N
[16]  A[G]{<-}2+({floor}0.25{times}A[G])-A[G]{<-}{floor}0.01{times}D[G;1]
[17]  A{<-}{neg}1524.5+D[;3]+A+({floor}365.25{times}D[;1]+4716)+{floor}30.{+
   +}6001{times}D[;2]+1
     {del}

     {del}A{<-}LEAPYR Y
[1]   A{<-}2|+{slashbar}0= 4 100 400 {jot}.|Y
     {del}

     {del}A{<-}TFMT T
[1]   #ERROR(3>{neg}1{take}{rho}T)/'LENGTH ERROR'
[2]   T{<-}({neg}2{take}1,{rho}T){rho}T
[3]   T{<-}T[;(1{drop}{rho}T){take} 2 3 1 4 5 6 7]
[4]   A{<-}'ZI2,</>,ZI2,</>,ZI4,P<  >ZI4,P<:>ZI3,P<:>ZI3,P<.>ZI4' #FMT T
     {del}

     {del}A{<-}TIMEBASE D;G;N;#IO





[6]   #IO{<-}1
[7]   D{<-}{transpose}({neg}2{take} 1 1 ,{rho}D){rho}D
[8]   D{<-}(7,N{<-}1{drop}{rho}D){take}D
[9]   G{<-}(D[2;]{<=}2)/{iota}N
[10]  D[1;G]{<-}D[1;G]-1
[11]  D[2;G]{<-}D[2;G]+12
[12]  A{<-}N{rho}0
[13]  G{<-}(15821004< 10000 100 100 {basevalue}(3,N){take}D)/{iota}N
[14]  A[G]{<-}2+({floor}0.25{times}A[G])-A[G]{<-}{floor}0.01{times}D[1;G]
[15]  A{<-}{neg}2416545+D[3;]+A+({floor}365.25{times}D[1;]+4716)+{floor}30.{+
   +}6001{times}D[2;]+1
[16]  A{<-}(24 60 60 1000 {basevalue} 3 0 {split}D)+86400000{times}A
     {del}

     {del}A{<-}TIMEFMT T
[1]   #ERROR(3>{neg}1{take}{rho}T)/'LENGTH ERROR'
[2]   T{<-}({neg}2{take}1,{rho}T){rho}T
[3]   T[;1]{<-}100|T[;1]
[4]   T{<-}T[;(1{drop}{rho}T){take} 2 3 1 4 5 6 7]
[5]   A{<-}'I2,</>,ZI2,</>,ZI2,I4,P<:>ZI3,P<:>ZI3,P<.>ZI4' #FMT T
     {del}

     {del}A{<-}TIMEREP T;C;D;E;M;#IO





[6]   #IO{<-}1
[7]   T{<-} 0 24 60 60 1000 {represent},T
[8]   A{<-}{floor}(T[1;]+547804.25){divide}36524.25
[9]   A{<-}T[1;]+2416546+A-{floor}0.25{times}A
[10]  D{<-}{floor}365.25{times}C{<-}{floor}(A-122.1){divide}365.25
[11]  E{<-}{floor}(A-D){divide}30.6001
[12]  M{<-}E-1+12{times}E>13
[13]  A{<-}{transpose}(C-4715+M>2),[1]M,[1](A-D+{floor}30.6001{times}E),[1] {+
   +}1 0 {split}T
     {del}

{del}---- End of workspace



Tue, 13 Oct 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Redefining keyboard with APL*PLUS DOS SE

2. Timing simulation problem with ModelSim SE Plus 5.6c

3. TIME&DATE in HTML shows TIME

4. HELP - APL*Plus III & Spread/VBX

5. Create Time / date or Modified Time / date of a txt file

6. convert labview date/time to excel date/time

7. DOS compressed date/time into real date/time

8. Edit fns under program control - APL+Win 3.0.00

9. Converting Dyalog APL Multiple Assignments to APL*PLUS

10. Porting APL*PLUS/PC to APL.68000

11. Porting Mainframe APL to APL*PLUS/PC

12. Translating COMPLEX.AWS from STSC APL-PLUS to generic APL

 

 
Powered by phpBB® Forum Software