Subversion Repositories wimsdev

Rev

Rev 9036 | Rev 11242 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

!if $wims_read_parm!=slib_header
 !goto proc
!endif

slib_author=Bernadette, Perrin-Riou
slib_title=Date
slib_parms=2\
 ,first date (written in format ddmmyyyy)\
 ,second date (written in format ddmmyyyy)\
diff,option as diff, add


slib_out=number of days between the two dates.
slib_example=12022013,18082013,diff\
12022013,13022013,diff\
12022013,18082013,diff\
18082013,12022013\
12022004,18082004\
17012012,10092014\
17012013,10092015\
17032013,10092013\
01022004,01032004\
12022013,0,add\
12022013,20,add\
04032013,-20,add\
12022013,3,add item\
18082013,365,add nospace\
18022012,365,add
!exit

:proc
!distribute item $wims_read_parm into slib_date1, slib_date2, slib_option
!if add isin $slib_option
  slib_date1=!nospace $slib_date1
  slib_date1=!text expand $slib_date1 using 01101101111
  slib_date1=!exec date.pl 1 $slib_date1
  slib_date2=!exec pari $slib_date1 + ($slib_date2)*86400
  slib_date2=!exec date.pl 2 $slib_date2
  slib_out=!word 1 to 3 of $(slib_date2)
  !if nospace isin $slib_option
    slib_out=!nospace $slib_out
  !endif
  !if item isin $slib_option
    slib_out=!words2items $slib_out
  !endif
!else
  slib_date1=!text expand $slib_date1 using 01101101111
  slib_date2=!text expand $slib_date2 using 01101101111
  slib_date1=!exec date.pl 1 $slib_date1
  slib_date2=!exec date.pl 1 $slib_date2
!! not always an integer because of the time change
  slib_out=$[round(($slib_date2 - $slib_date1)/86400)]
!endif