Untitled Diff

Created Diff never expires
1 removal
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
61 lines
10 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
69 lines
@echo off
@echo off




rem les dates
rem les dates
set date1=14/05/1643
set date1=14/05/1643
set date2=01/09/1715
set date2=01/09/1715






rem on récupère la différence en jours entre les deux dates
rem on récupère la différence en jours entre les deux dates
call :Date.DiffenceBetweenDate %date1% %date2% days
call :Date.DiffenceBetweenDate %date1% %date2% days


rem on affiche le calcul
rem on affiche le calcul
echo;%date2% - %date1% = %days% jours
echo;%date2% - %date1% = %days% jours


rem on format le résultat
rem on format le résultat
call :Date.DiffenceBetweenDateFormat %date1% %date2% year month week day
call :Date.DiffenceBetweenDateFormat %date1% %date2% year month week day


rem on affiche le résultat
rem on affiche le résultat
echo;%year% annees; %month% mois; %week% semaines; %day% jours
echo;%year% annees; %month% mois; %week% semaines; %day% jours








rem les fonctions
rem les fonctions
pause>nul&exit
pause>nul&exit
:Date.toDays <days> <month> <year> <out:days>
:Date.toDays <days> <month> <year> <out:days>
setlocal enabledelayedexpansion
setlocal enabledelayedexpansion
set /a d=1%~1+1%~1-2%~1&set /a m=1%~2+1%~2-2%~2&set /a y=1%~3+1%~3-2%~3
set /a d=1%~1+1%~1-2%~1&set /a m=1%~2+1%~2-2%~2&set /a y=1%~3+1%~3-2%~3
set /a "m=(%m%+9) %% 12"&set /a "y=%y%-!m!/10"
set /a "m=(%m%+9) %% 12"&set /a "y=%y%-!m!/10"
(endlocal&set /a "%~4=365*%y%+%y%/4-%y%/100+%y%/400+(%m%*306+5)/10+(%d%-1)")
(endlocal&set /a "%~4=365*%y%+%y%/4-%y%/100+%y%/400+(%m%*306+5)/10+(%d%-1)")
exit /b
exit /b
:Date.DiffenceBetweenDate <DD/MM/YYYY> <DD/MM/YYYY> <out:days>
:Date.DiffenceBetweenDate <DD/MM/YYYY> <DD/MM/YYYY> <out:days>
setlocal enabledelayedexpansion
setlocal enabledelayedexpansion
set date1=%~1&set date2=%~2
set date1=%~1&set date2=%~2
call :Date.toDays !date1:/= ! g1&call :Date.toDays !date2:/= ! g2
call :Date.toDays !date1:/= ! g1&call :Date.toDays !date2:/= ! g2
(endlocal&set /a "%~3=%g2%-%g1%")
(endlocal&set /a "%~3=%g2%-%g1%")
exit /b
exit /b
:Date.getFrom <DD/MM/YYYY> <out:year> <out:month> <out:day>
:Date.getFrom <DD/MM/YYYY> <out:year> <out:month> <out:day>
for /f "tokens=1-3 delims=/,-\ " %%1 in ('echo;%~1') do (
for /f "tokens=1-3 delims=/,-\ " %%1 in ('echo;%~1') do (
set /a %~2=1%%~1+1%%~1-2%%~1
set /a %~2=1%%~1+1%%~1-2%%~1
set /a %~3=1%%~2+1%%~2-2%%~2
set /a %~3=1%%~2+1%%~2-2%%~2
set /a %~4=1%%~3+1%%~3-2%%~3
set /a %~4=1%%~3+1%%~3-2%%~3
)
)
exit /b
exit /b
:Date.DiffenceBetweenDateFormat <DD/MM/YYYY> <DD/MM/YYYY> <out:year> <out:month> <out:week> <out:day>
:Date.DiffenceBetweenDateFormat <DD/MM/YYYY> <DD/MM/YYYY> <out:year> <out:month> <out:week> <out:day>
setlocal enabledelayedexpansion
setlocal enabledelayedexpansion
call :Date.getFrom %~1 d1 m1 y1
call :Date.getFrom %~1 d1 m1 y1
call :Date.getFrom %~2 d2 m2 y2
call :Date.getFrom %~2 d2 m2 y2
set /a "totalmonths=(%y2% - %y1%) * 12 + %m2% - %m1%"
set /a "totalmonths=(%y2% - %y1%) * 12 + %m2% - %m1%"
if %d2% lss %d1% set /a totalmonths-=1
if %d2% lss %d1% set /a totalmonths-=1
set /a month=%totalmonths% %% 12 + %m1%
set /a month=%totalmonths% %% 12 + %m1%
call :Date.DiffenceBetweenDate %d1%/%month%/%y2% %date2% day
set /a yeartmp=%totalmonths% / 12
set /a monthtmp=%totalmonths% %% 12
set /a y3=%y1%+%yeartmp%
set /a m3=%m1%+%monthtmp%
if %m3% gtr 12 (
set /a m3=%m3%-12
set /a y3+=1
)
call :Date.DiffenceBetweenDate %d1%/%m3%/%y3% %~2 day
(
(
endlocal
endlocal
set /a %~3=%totalmonths% / 12
set /a %~3=%totalmonths% / 12
set /a %~4=%totalmonths% %% 12
set /a %~4=%totalmonths% %% 12
set /a %~5=%day%/7
set /a %~5=%day%/7
set /a %~6=%day% %% 7
set /a %~6=%day% %% 7
)
)
exit /b
exit /b