;+____________________________________________________________________________ ;_ ;_ Date-time routines from PRASSADCO ;-____________________________________________________________________________ FUNCTION MJD2STR, mjd, roundsec=roundsec, nosep=nosep, mos=mos ;+ ; tstr= mjd2str(mjd) ; ; PURPOSE: converts modified julian date (double precision float) ; to a string representation of date/time ; ; INPUT: mjd .... modified julian date in double precision float ; could be an array ; OUTPUT: tstr .... string or string array formatted as follows (23 chars): ; 'YYYY-MM-DD HH:MM:SS.MSC' ; (YYYY year, MM month, DD day, HH hour, MM min, SS sec, MSC msec) ; KEYWORDS: roundsec .... if set the output is in the form (19 chars) ; 'YYYY-MM-DD HH:MM:SS' ; nosep ... if set, ' ' is used to separate items (YYYY MM DD HH MM....) ; ; mos ... month as string DD-MON-YYYY ;- mosn=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] if n_elements(roundsec) le 0 then roundsec=0 sep=['1h-','1h-','1x','1h:','1h:','1h.'] if keyword_set(nosep) then sep=['1x','1x','1x','1x','1x','1x'] caltime,mjd,i,s,m,h,d,n,y,roundsec=roundsec nel=n_elements(mjd) if nel eq 1 then begin y=y(0) & n=n(0) & d=d(0) & h=h(0) & m=m(0) & s=s(0) & i=i(0) endif if keyword_set(mos) then begin if not keyword_set(roundsec) then begin trec=replicate({d:0,n:'abc',y:0,h:0,m:0,s:0,i:0},nel) trec.y=y & trec.n=mosn(n-1) & trec.d=d & trec.h=h & trec.m=m & trec.s=s & trec.i=i endif else begin trec=replicate({d:0,n:'abc',y:0,h:0,m:0,s:0},nel) trec.y=y & trec.n=mosn(n-1) & trec.d=d & trec.h=h & trec.m=m & trec.s=s endelse endif else begin if not keyword_set(roundsec) then begin trec=replicate({y:0,n:0,d:0,h:0,m:0,s:0,i:0},nel) trec.y=y & trec.n=n & trec.d=d & trec.h=h & trec.m=m & trec.s=s & trec.i=i endif else begin trec=replicate({y:0,n:0,d:0,h:0,m:0,s:0},nel) trec.y=y & trec.n=n & trec.d=d & trec.h=h & trec.m=m & trec.s=s endelse endelse tstr=strarr(nel) buf=1000L nin=long(ceil(float(nel)/float(buf))) for i=0L,nin-1 do begin ni=min([buf,nel-i*buf]) if keyword_set(mos) then begin if not keyword_set(roundsec) then begin tstr(i*buf:i*buf+ni-1)=string(trec(i*buf:i*buf+ni-1),$ format='('+string(ni)+'(I2.2,'+sep(0)+',A3,'+sep(1)+',I4.4,'+sep(2)+$ ',I2.2,'+sep(3)+',I2.2,'+sep(4)+',I2.2,'+sep(5)+',I3.3/))') endif else begin tstr(i*buf:i*buf+ni-1)=string(trec(i*buf:i*buf+ni-1),$ format='('+string(ni)+'(I2.2,'+sep(0)+',A3,'+sep(1)+',I4.4,'+sep(2)+$ ',I2.2,'+sep(3)+',I2.2,'+sep(4)+',I2.2/))') endelse endif else begin if not keyword_set(roundsec) then begin tstr(i*buf:i*buf+ni-1)=string(trec(i*buf:i*buf+ni-1),$ format='('+string(ni)+'(I4.4,'+sep(0)+',I2.2,'+sep(1)+',I2.2,'+sep(2)+$ ',I2.2,'+sep(3)+',I2.2,'+sep(4)+',I2.2,'+sep(5)+',I3.3/))') endif else begin tstr(i*buf:i*buf+ni-1)=string(trec(i*buf:i*buf+ni-1),$ format='('+string(ni)+'(I4.4,'+sep(0)+',I2.2,'+sep(1)+',I2.2,'+sep(2)+$ ',I2.2,'+sep(3)+',I2.2,'+sep(4)+',I2.2/))') endelse endelse endfor return,tstr END