────────── Moderator Note ──────────
For the improved code, please see qzwqzw's script on the 20th floor
────────── Moderator Note ──────────
::Algorithm: Kim Larsen calculation formula
::W= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7
::In the calendar ★=today
::Leap year calculation has not been added yet. So every February has 28 days
[ Last edited by bjsh on 2007-7-31 at 02:36 PM ]
For the improved code, please see qzwqzw's script on the 20th floor
────────── Moderator Note ──────────
::Algorithm: Kim Larsen calculation formula
::W= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7
::In the calendar ★=today
::Leap year calculation has not been added yet. So every February has 28 days
@echo off& color 27 & mode con cols=40 lines=20 & title Calendar, made by 泛滥棏慌°.QQ:173459058&&setlocal enabledelayedexpansion
set dated=%date%
:home
cls&echo/
set zdate=%date%
set y=%zdate:~0,4%
set m=%zdate:~5,2%
set d=%date:~8,2%
if %d% geq 32 (echo Invalid date.&pause>nul&exit)
set d1=01
if "%m%"=="01" (set /a y-=1& set /a m+=12)
if "%m%"=="02" (set /a y-=1& set /a m+=12)
::Week calculation formula
set /a w=(%d1%+2*%m%+3*(%m%+1)/5+%y%+%y%/4-%y%/100+%y%/400)%%7+1
set /a ww=(%d%+2*%m%+3*(%m%+1)/5+%y%+%y%/4-%y%/100+%y%/400)%%7+1
set 1=Mon&set 2=Tue&set 3=Wed&set 4=Thu&set 5=Fri&set 6=Sat&set 7=Sun
if "%date%"=="%dated%" (
echo This is the %date:~0,4%-%date:~5,2% calendar Today:%dated:~0,4%!-%dated:~5,2%-%dated:~8,2%
) else (
echo This is the %date:~0,4%-%date:~5,2% calendar ★=today
echo The date you queried is:%date%, week!%ww%!
)
::Leap year calculation has not been added yet. So every February has 28 days
set %m%m=31&set %m%m=28&set %m%m=31&set %m%m=30&set %m%m=31&set %m%m=30
set %m%m=31&set %m%m=31&set %m%m=30&set %m%m=31&set %m%m=30&set %m%m=31
set /a cyc=!%m%m!+%w%-1
set n=0
for /l %%i in (0,1,40) do (set w%%i= )
for /l %%i in (%w%,1,%cyc%) do (
set /a n+=1
set w%%i=0!n!
if !n! GEQ 10 set w%%i=!n!
if !n! EQU !d! set w%%i=★
)
echo/
echo Sun Mon Tue Wed Thu Fri Sat
echo ━━━━━━━━━━━━━━━━━━━━
echo %w0% %w1% %w2% %w3% %w4% %w5% %w6%
echo.
echo %w7% %w8% %w9% %w10% %w11% %w12% %w13%
echo.
echo %w14% %w15% %w16% %w17% %w18% %w19% %w20%
echo.
echo %w21% %w22% %w23% %w24% %w25% %w26% %w27%
echo.
echo %w28% %w29% %w30% %w31% %w32% %w33% %w34%
echo ━━━━━━━━━━━━━━━━━━━━
echo Enter year-month-day to view that month's calendar and the weekday of that day
set /p date=Format like (2007-02-03)-Exit:
if /i "%date%"=="E" exit
goto :home [ Last edited by bjsh on 2007-7-31 at 02:36 PM ]

DigestI