Subversion Repositories wimsdev

Rev

Rev 11459 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8778 bpr 1
!if $wims_read_parm!=slib_header
13594 bpr 2
  !goto proc
8778 bpr 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
 
11273 bpr 12
slib_out=<ul><li>with parameter <code>diff</code> (default), returns the number of days between the two dates.</li>\
13
  <li>with parameter <code>add</code>, returns the new date obtaining by adding the date plus the number of days</li>\
14
  <li>with parameter <code>add</code>, you can also add the parameter <code>item</code> to return\
15
   the date in a comma separated values format or the parameter <code>nospace</code> \
16
   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\
11459 bpr 26
18082013,365,add nospace
8778 bpr 27
!exit
28
 
29
:proc
9640 bpr 30
!distribute item $wims_read_parm into slib_date1, slib_date2, slib_option
31
!if add isin $slib_option
32
  slib_date1=!nospace $slib_date1
33
  slib_date1=!text expand $slib_date1 using 01101101111
34
  slib_date1=!exec date.pl 1 $slib_date1
35
  slib_date2=!exec pari $slib_date1 + ($slib_date2)*86400
36
  slib_date2=!exec date.pl 2 $slib_date2
37
  slib_out=!word 1 to 3 of $(slib_date2)
38
  !if nospace isin $slib_option
39
    slib_out=!nospace $slib_out
40
  !endif
41
  !if item isin $slib_option
42
    slib_out=!words2items $slib_out
43
  !endif
8778 bpr 44
!else
9640 bpr 45
  slib_date1=!text expand $slib_date1 using 01101101111
46
  slib_date2=!text expand $slib_date2 using 01101101111
47
  slib_date1=!exec date.pl 1 $slib_date1
48
  slib_date2=!exec date.pl 1 $slib_date2
13594 bpr 49
  !! not always an integer because of the time change
9640 bpr 50
  slib_out=$[round(($slib_date2 - $slib_date1)/86400)]
8778 bpr 51
!endif