Subversion Repositories wimsdev

Rev

Rev 9036 | Rev 11242 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9036 Rev 9640
Line 4... Line 4...
4
 
4
 
5
slib_author=Bernadette, Perrin-Riou
5
slib_author=Bernadette, Perrin-Riou
6
slib_title=Date
6
slib_title=Date
7
slib_parms=2\
7
slib_parms=2\
8
 ,first date (written in format ddmmyyyy)\
8
 ,first date (written in format ddmmyyyy)\
9
 ,second date (written in format ddmmyyyy)
9
 ,second date (written in format ddmmyyyy)\
-
 
10
diff,option as diff, add
-
 
11
 
10
 
12
 
11
slib_out=number of days between the two dates.
13
slib_out=number of days between the two dates.
12
slib_example=12022013,18082013\
14
slib_example=12022013,18082013,diff\
13
12022013,13022013\
15
12022013,13022013,diff\
14
12022013,18082013\
16
12022013,18082013,diff\
15
18082013,12022013\
17
18082013,12022013\
16
12022004,18082004\
18
12022004,18082004\
17
17012012,10092014\
19
17012012,10092014\
18
17012013,10092015\
20
17012013,10092015\
19
17032013,10092013\
21
17032013,10092013\
20
01022004,01032004
22
01022004,01032004\
-
 
23
12022013,0,add\
-
 
24
12022013,20,add\
-
 
25
04032013,-20,add\
-
 
26
12022013,3,add item\
-
 
27
18082013,365,add nospace\
-
 
28
18022012,365,add
21
!exit
29
!exit
22
 
30
 
23
:proc
31
:proc
24
on ne tient compte pas des années bissextiles !
-
 
25
!distribute item $wims_read_parm into slib_date1, slib_date2
32
!distribute item $wims_read_parm into slib_date1, slib_date2, slib_option
26
!set slib_day1=!char 1 to 2 of $slib_date1
33
!if add isin $slib_option
27
!set slib_day2=!char 1 to 2 of $slib_date2
34
  slib_date1=!nospace $slib_date1
28
!set slib_month1=!char 3 to 4 of $slib_date1
35
  slib_date1=!text expand $slib_date1 using 01101101111
29
!set slib_month2=!char 3 to 4 of $slib_date2
36
  slib_date1=!exec date.pl 1 $slib_date1
30
!set slib_year1=!char 5 to 8 of $slib_date1
37
  slib_date2=!exec pari $slib_date1 + ($slib_date2)*86400
31
!set slib_year2=!char 5 to 8 of $slib_date2
38
  slib_date2=!exec date.pl 2 $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
39
  slib_out=!word 1 to 3 of $(slib_date2)
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
40
  !if nospace isin $slib_option
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
41
    slib_out=!nospace $slib_out
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
42
  !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
43
  !if item isin $slib_option
60
    !endif
-
 
61
  !next
-
 
62
  !set slib_nb=$[$slib_nb + $(slib_day2)]
44
    slib_out=!words2items $slib_out
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
45
  !endif
68
  !next
-
 
69
!endif
46
!else
70
 
-
 
71
!if $slib_month1 > $slib_month2
-
 
72
on change d'annee
-
 
73
  !set slib_nb=$[$(slib_month_list[$slib_month1])-$slib_day1+1]
47
  slib_date1=!text expand $slib_date1 using 01101101111
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
48
  slib_date2=!text expand $slib_date2 using 01101101111
77
     !increase slib_nb
-
 
78
    !endif
-
 
79
  !next
-
 
80
  !for slib_j=1 to $slib_month2-1
49
  slib_date1=!exec date.pl 1 $slib_date1
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)]
50
  slib_date2=!exec date.pl 1 $slib_date2
87
  !for slib_j=$slib_year1 to $slib_year2 -1
51
!! not always an integer because of the time change
88
    !set slib_nb=$[$slib_nb + 365]
-
 
89
    !if $slib_j%4=0 and $slib_year1%100!=0
52
  slib_out=$[round(($slib_date2 - $slib_date1)/86400)]
90
      !increase $slib_nb
-
 
91
    !endif
-
 
92
  !next
-
 
93
!endif
-
 
94
 
-
 
95
slib_out=$[$slib_nb-1]
-
 
96
!if $slib_sign=-1
-
 
97
  slib_out=-$slib_out
-
 
98
!endif
53
!endif