; $Id: dcs_datestring.pro,v 1.4 2005/02/14 17:50:33 azuah Exp $
; Written by J.R.D. Copley.
;************************************************************************************************
;###############################################################################
;
; LICENSE:
;  The software in this file is written by an employee of 
;  National Institute of Standards and Technology 
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used or if the code in this file is
;  included in another product.
;
;###############################################################################
pro dcs_datestring,yesterday,today,tomorrow
;************************************************************************************************
; This routine generates 8-character strings of the form "20001027" corresponding to yesterday's
; date, today's date, and tomorrow's date.
;
compile_opt strictarr
;
months=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]
dmonth=[" 01"," 02"," 03"," 04"," 05"," 06"," 07"," 08"," 09"," 10"," 11"," 12"]
systime=systime()
year=strmid(systime,20)
day=strmid(systime,8,2)
month=strmid(systime,4,3)
month=where(strlowcase(month) eq months)
month=dmonth[month]
today=year+strmid(month,1)+day
y=fix(year)
m=fix(month[0])
d=fix(day)
j=julday(m,d,y)-1
caldat,j,m,d,y
stringy=string(y)
if (d lt 10) then stringd=" 0"+string(d) else stringd=string(d)
yesterday=strcompress(stringy+dmonth[m-1]+stringd,/remove_all)
j=j+2
caldat,j,m,d,y
stringy=string(y)
if (d lt 10) then stringd=" 0"+string(d) else stringd=string(d)
tomorrow=strcompress(stringy+dmonth[m-1]+stringd,/remove_all)
end