Rev 8787 | Rev 9640 | 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)\ |
9 | ,second date (written in format ddmmyyyy) |
||
8778 | bpr | 10 | |
9036 | bpr | 11 | slib_out=number of days between the two dates. |
8778 | bpr | 12 | slib_example=12022013,18082013\ |
8787 | bpr | 13 | 12022013,13022013\ |
8779 | bpr | 14 | 12022013,18082013\ |
8778 | bpr | 15 | 18082013,12022013\ |
16 | 12022004,18082004\ |
||
17 | 17012012,10092014\ |
||
18 | 17012013,10092015\ |
||
8779 | bpr | 19 | 17032013,10092013\ |
8778 | bpr | 20 | 01022004,01032004 |
21 | !exit |
||
22 | |||
23 | :proc |
||
24 | on ne tient compte pas des années bissextiles ! |
||
25 | !distribute item $wims_read_parm into slib_date1, slib_date2 |
||
26 | !set slib_day1=!char 1 to 2 of $slib_date1 |
||
27 | !set slib_day2=!char 1 to 2 of $slib_date2 |
||
28 | !set slib_month1=!char 3 to 4 of $slib_date1 |
||
29 | !set slib_month2=!char 3 to 4 of $slib_date2 |
||
30 | !set slib_year1=!char 5 to 8 of $slib_date1 |
||
31 | !set slib_year2=!char 5 to 8 of $slib_date2 |
||
32 | !if $slib_year2 < $slib_year1 or ($slib_year2 = $slib_year1 and $slib_month2 < $slib_month1)\ |
||
33 | or ($slib_year2 = $slib_year1 and $slib_month2 < $slib_month1 and $slib_day2 < $slib_day1) |
||
34 | !exchange slib_day1 and slib_day2 |
||
35 | !exchange slib_month1 and slib_month2 |
||
36 | !exchange slib_year1 and slib_year2 |
||
37 | !set slib_sign=-1 |
||
38 | !else |
||
39 | !set slib_sign=1 |
||
40 | !endif |
||
41 | !set slib_month1=$[$slib_month1] |
||
42 | !set slib_month2=$[$slib_month2] |
||
43 | !set slib_month_list=31,27,31,30,31,30,31,31,30,31,30,31 |
||
44 | pour l'instant même année donc slib_month1 <= $slib_month2 |
||
45 | !if $slib_month1 = $slib_month2 |
||
46 | !set slib_nb=$[$slib_day2-$slib_day1+1] |
||
47 | !if $slib_month1=2 and $[$slib_year1%4]=0 and $[$slib_year1%100]!=0 |
||
48 | !increase slib_nb |
||
49 | !endif |
||
50 | !endif |
||
51 | !if $slib_month1 < $slib_month2 |
||
52 | !set slib_nb=$[$(slib_month_list[$slib_month1])-$slib_day1+1] |
||
53 | !if $slib_month1=2 and $[$slib_year1%4]=0 and $[$slib_year1%100]!=0 |
||
54 | !increase slib_nb |
||
55 | !endif |
||
56 | !for slib_j=$slib_month1+1 to $[$slib_month2-1] |
||
57 | !set slib_nb=$[$slib_nb + $(slib_month_list[$slib_j])] |
||
58 | !if $slib_j=2 and $[$slib_year1%4]=0 and $[$slib_year1%100]!=0 |
||
59 | !increase slib_nb |
||
60 | !endif |
||
61 | !next |
||
62 | !set slib_nb=$[$slib_nb + $(slib_day2)] |
||
63 | !for slib_j=$slib_year1 to $slib_year2 -1 |
||
64 | !set slib_nb=$[$slib_nb + 365] |
||
65 | !if $slib_j%4=0 and $slib_year1%100!=0 |
||
66 | !increase $slib_nb |
||
67 | !endif |
||
68 | !next |
||
69 | !endif |
||
70 | |||
71 | !if $slib_month1 > $slib_month2 |
||
72 | on change d'annee |
||
73 | !set slib_nb=$[$(slib_month_list[$slib_month1])-$slib_day1+1] |
||
74 | !for slib_j=$slib_month1+1 to 12 |
||
75 | !set slib_nb=$[$slib_nb + $(slib_month_list[$slib_j])] |
||
76 | !if $slib_j=2 and $slib_year1%4=0 and $slib_year1%100!=0 |
||
77 | !increase slib_nb |
||
78 | !endif |
||
79 | !next |
||
80 | !for slib_j=1 to $slib_month2-1 |
||
81 | !set slib_nb=$[$slib_nb + $(slib_month_list[$slib_j])] |
||
82 | !if $slib_j=2 and $[($slib_year1+1)%4]=0 and $[($slib_year1+1)%100]!=0 |
||
83 | !increase slib_nb |
||
84 | !endif |
||
85 | !next |
||
86 | !set slib_nb=$[$slib_nb + $(slib_day2)] |
||
87 | !for slib_j=$slib_year1 to $slib_year2 -1 |
||
88 | !set slib_nb=$[$slib_nb + 365] |
||
89 | !if $slib_j%4=0 and $slib_year1%100!=0 |
||
90 | !increase $slib_nb |
||
91 | !endif |
||
92 | !next |
||
93 | !endif |
||
94 | |||
8787 | bpr | 95 | slib_out=$[$slib_nb-1] |
8778 | bpr | 96 | !if $slib_sign=-1 |
97 | slib_out=-$slib_out |
||
98 | !endif |