『楼 主』:
[原创]批处理版日期查询器。(欢迎大家测试)
注:查询年份从1904年起往后。
@echo off&color 9f&mode con lines=10
title 星期查询器
:set
cls
echo.&echo.&echo.
set var=
set /p var= 请输入要查询的日期(格式为2000年08月08日):
if "%var:~4,1%%var:~7,1%%var:~10,1%"=="年月日" goto year
cls
echo.&echo.&echo.
echo 输入格式不正确!请返回正确输入。&ping /n 3 127.1>nul&goto set
:year
set year=%var:~,4%
set /a str=(%year%-1904)/4&set /a str1=%year%-1904
for /l %%i in (0,1,3) do (
set a=%%i
setlocal enabledelayedexpansion
set /a str2=4*!str!+!a!
if !str1! equ !str2! goto month
)
:month
endlocal
if %a% equ 0 (set /a number1=%str%*1461) else (set /a number1=%str%*1461+%a%*365+1)
if %var:~5,1% equ 0 (set month=%var:~6,1%) else (set month=%var:~5,2%)
set /a month=%month%-1
if %month% equ 0 set /a number2=0&goto day
if %month% equ 1 set /a number2=31&goto day
if %month% equ 2 set /a number2=31+28
if %month% equ 3 set /a number2=31*2+28
if %month% equ 4 set /a number2=31*2+30+28
if %month% equ 5 set /a number2=31*3+30+28
if %month% equ 6 set /a number2=31*3+30*2+28
if %month% equ 7 set /a number2=31*4+30*2+28
if %month% equ 8 set /a number2=31*5+30*2+28
if %month% equ 9 set /a number2=31*5+30*3+28
if %month% equ 10 set /a number2=31*6+30*3+28
if %month% equ 11 set /a number2=31*6+30*4+28
if %a% equ 0 set /a number2=%number2%+1
:day
if %var:~8,1% equ 0 (set day=%var:~9,1%) else (set day=%var:~8,2%)
set /a number3=%day%-1
:week
set /a number=%number1%+%number2%+%number3%
set /a week=%number%/7
for /l %%i in (0,1,6) do (
set b=%%i
setlocal enabledelayedexpansion
set /a str=!week!*7+!b!
if !str! equ !number! goto echo
)
:echo
endlocal
set code=五六天一二三四
set /a move=%b%
cls
echo.&echo.&echo.
call,echo %var%那天是星期%%code:~%move%,1%%
pause>nul
cls
echo.&echo.&echo.
echo 本次查询结束,按键继续,结束请直接关闭窗口。
pause>nul&goto set [ Last edited by zw19750516 on 2008-4-6 at 04:40 PM ]
|