Create time table

Hi

I'm want to create a time table which interpolation in IGOR
I've try to calculate the seconds passed since 1904/01/01 00:00 by following code
But still won't work, I can't figure out what's going on

I new a table which show as

YEAR MONTH DAY HOUR MINUTE
2017 2 1 0 0
2017 2 1 1 0
2017 2 1 2 0

<br />
#pragma rtGlobals=1     // Use modern global access method.<br />
Macro test()<br />
<br />
Variable/G t1,t2,dt<br />
String sdate="20170201_0000" // Start Time: YYYYMMDD_HHMM<br />
String edate="20170201_0200" // End Time: YYYYMMDD_HHMM<br />
Variable inter_min=60 // Interpolation with N minute<br />
Variable inter_sec<br />
String ssy=sdate[0,3] , eey=edate[0,3]<br />
String ssm=sdate[4,5] , eem=edate[4,5]<br />
String ssd=sdate[6,7] , eed=edate[6,7]<br />
String ssh=sdate[9,10] , eeh=edate[9,10]<br />
String ssn=sdate[11,12] , een=edate[11,12]<br />
Variable sy=str2num(ssy) , ey=str2num(eey)<br />
Variable sm=str2num(ssm) , em=str2num(eem)<br />
Variable sd=str2num(ssd)  , ed=str2num(eed)<br />
Variable sh=str2num(ssh)  , eh=str2num(eeh)<br />
Variable sn=str2num(ssn)  , en=str2num(een)<br />
<br />
en=en+inter_min<br />
<br />
If  (inter_min==60)<br />
    inter_sec=3600<br />
Endif<br />
<br />
t1=date2secs(sy,sm,sd)+sh*60*60+sn*60+0 //calculate start time seconds<br />
t2=date2secs(ey,em,ed)+eh*60*60+en*60+0 //calculate end time seconds<br />
<br />
dt=abs(t2-t1)/inter_sec    // total row<br />
<br />
Make/D/N=(dt) secs,year,month,day,hour,minute<br />
Edit secs,year,month,day,hour,minute<br />
SetScale x,t1,t2,"dat",secs<br />
secs=x<br />
Variable num <br />
Variable allnum=dt<br />
<br />
Variable year_sec, month<br />
Variable totaldays,temp, temp_year, temp_month, temp_days, temp_hour, temp_min<br />
<br />
Do<br />
temp=(secs[num]/31557600)  <br />
temp_year=round(temp+1904)<br />
year[num]=temp_year <br />
<br />
temp=date2secs(temp_year,01,01)+00*60*60+00*60+0<br />
temp=ceil((secs[num]-temp)/86400)+1<br />
print temp<br />
<br />
If(year_temp==2012 ||  year_temp==2016)<br />
totaldays=366<br />
    If((temp>=1) && (temp<=31))<br />
    temp_month=1<br />
    temp_days=temp<br />
    Endif<br />
    if((temp>31) && (temp<=60))<br />
    temp_month=2<br />
    temp_days=temp-31<br />
    endif<br />
    if((temp>60) && (temp<=91))<br />
    temp_month=3<br />
    temp_days=temp-31-29<br />
    endif<br />
Endif<br />
<br />
If((year_temp!=2012) ||  (year_temp!=2016))<br />
totaldays=365<br />
    If((temp>=1) && (temp<=31))<br />
    temp_month=1<br />
    temp_days=temp<br />
    endif<br />
    if((temp>31) && (temp<=59))<br />
    temp_month=2<br />
    temp_days=temp-31<br />
    endif<br />
    if((temp>59) && (temp<=91))<br />
    temp_month=3<br />
    temp_days=temp-31-28<br />
    Endif<br />
Endif<br />
<br />
month[num]=temp_month<br />
day[num]=temp_days<br />
temp=date2secs(temp_year,temp_month,temp_days)+00*60*60+00*60+0<br />
temp=(secs[num]-temp)/3600  <br />
temp_hour=floor(temp)<br />
hour[num]=temp_hour<br />
<br />
num+=1<br />
While(num<=dt)<br />
<br />
Endmacro<br />
<pre><code class="language-igor"></span>
Please use <pre><code class="language-igor">&lt;/ccode&gt; ... &lt;ccode&gt;</code></pre> tags for Igor code. It's easier to read for us :-)

"Won't work" is not a good description. Does it not compile? Is the result wrong? ...?

Maybe you want to have a look at
displayhelptopic "date2secs"
That should do some of the work. Hours, minutes and seconds on top are easy.
Consider to use functions rather than macros.

HJ

PS: Timestamps in waves require double precision waves