@echo off
{::setlocal enabledelayedexpansion It is no need to add in! }
set dy=%date:~0,4%
set dm=%date:~5,2%
set dd=%date:~8,2%
echo Today is : %dy%-%dm%-%dd%
echo Calculate the date after 100 days.
echo.
pause>nul
rem First check if the date dd is in the following conditions (3-12), consider January and February specially!
rem Also, the default is that the year dy is a common year, and finally consider leap years.
rem So just add one to dd at the end!
for %%i in (3,5,7,8,10,12) do (
rem Check Odd Month (single month).
if %dm% equ %%i (
set /a dm+=3
set /a dd+=8
rem At this time, dm has become a double month.
goto :checkdd
)
)
rem Check Even Month (double month).
for %%j in (4,6,9,11) do (
if %dm% equ %%j (
set /a dm+=3
set /a dd+=9
rem At this time, dm has become a single month.
goto :checkdd
)
)
::jan and feb
rem Consider the situation of January and February.
if %dm% equ 1 (
set /a dm+=3
set /a dd+=10
goto :checkdd
)
if %dm% equ 2 (
set /a dm+=3
set /a dd+=10
goto :checkdd
)
:checkdd
rem At this time, dm has become a double month.
rem Check if the date is greater than 30.
if %dd% gtr 30 (
rem For example, June 24th should be changed to July 2nd.
set /a dm+=1
set /a ddd=%dd%-30
)
rem At this time, dm has become a single month.
rem Check if the date is greater than 31.
if %dd% gtr 31 (
rem For example, July 24th should be changed to August 2nd.
set /a dm+=1
set /a ddd=%dd%-31
)
:checkYear {Here, Be careful , the code is not the same with the former I writed!}
rem Check if it is a common year or a leap year. As long as it is not a common year "... equ 0", add one to dd.
set /a rmn=dy%4
set /a rmnn=dy%400
if %rmn% neq 0 (echo This year is not leap year!)
if %rmn% equ 0 (
if %rmnn% equ 0 (
echo This year is leap year!
set /a dd+=1
)
)
::Output the Result.
echo The day after 100 days is: %dy%-%dm%-%dd%!
:: "Attach any code executable here!"
pause>nul