Subversion Repositories wimsdev

Rev

Rev 9640 | Rev 11273 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8778 bpr 1
!if $wims_read_parm!=slib_header
2
 !goto proc
3
!endif
4
 
5
slib_author=Bernadette, Perrin-Riou
6
slib_title=Date
7
slib_parms=2\
9036 bpr 8
 ,first date (written in format ddmmyyyy)\
11242 obado 9
 ,second date (written in format ddmmyyyy), or number of days to add\
9640 bpr 10
diff,option as diff, add
8778 bpr 11
 
9640 bpr 12
 
11242 obado 13
  slib_out=<ul><li>with parameter <code>diff</code> (default), returns the number of days between the two dates.</li>\
14
  <li>with parameter <code>add</code>, returns the first date plus the second number of days</li>\
15
  <li>with parameter <code>add</code>, you can add also add the parameter <code>item</code> to return the date in a comma separated values format.</li>\
16
  <li>with parameter <code>add</code>, you can add also add the parameter <code>nospace</code> to return a compacted format date (ddmmyyyy).</li></ul>
9640 bpr 17
slib_example=12022013,18082013,diff\
18
12022013,13022013,diff\
19
12022013,18082013,diff\
8778 bpr 20
18082013,12022013\
21
17012012,10092014\
9640 bpr 22
12022013,0,add\
23
12022013,20,add\
24
04032013,-20,add\
25
12022013,3,add item\
26
18082013,365,add nospace\
27
18022012,365,add
8778 bpr 28
!exit
29
 
30
:proc
9640 bpr 31
!distribute item $wims_read_parm into slib_date1, slib_date2, slib_option
32
!if add isin $slib_option
33
  slib_date1=!nospace $slib_date1
34
  slib_date1=!text expand $slib_date1 using 01101101111
35
  slib_date1=!exec date.pl 1 $slib_date1
36
  slib_date2=!exec pari $slib_date1 + ($slib_date2)*86400
37
  slib_date2=!exec date.pl 2 $slib_date2
38
  slib_out=!word 1 to 3 of $(slib_date2)
39
  !if nospace isin $slib_option
40
    slib_out=!nospace $slib_out
41
  !endif
42
  !if item isin $slib_option
43
    slib_out=!words2items $slib_out
44
  !endif
8778 bpr 45
!else
9640 bpr 46
  slib_date1=!text expand $slib_date1 using 01101101111
47
  slib_date2=!text expand $slib_date2 using 01101101111
48
  slib_date1=!exec date.pl 1 $slib_date1
49
  slib_date2=!exec date.pl 1 $slib_date2
50
!! not always an integer because of the time change
51
  slib_out=$[round(($slib_date2 - $slib_date1)/86400)]
8778 bpr 52
!endif