|  | 
 
| bat-zw 金牌会员
 
       永远的学习者
 
 
 积分 3105
 发帖 1276
 注册 2008-3-8
 状态 离线
 | 
|     『楼 主』:
 [原创]批处理版万年历(不断完善中)
 
使用 LLM 解释/回答一下 
 
 
注:查询年月从1904年01月起,因农历无法用程序进行计算,因此暂无农历显示,本人将继续完善。 
----------------------------------- 
四楼为加强版 
----------------------------------- 
十五楼为最终修正版(更新日期2008年4月20日) 
附件exe版:http://upload.cn-dos.net/img/248.rar @echo off&color 9f&mode con lines=20title 批处理版万年历
 :begin
 cls
 echo.&echo.&echo.&echo.&echo.
 set var=&set str=&set str1=&set str2=&set str3=&set n=0&set m=0&set v=0&set w=0
 set /p var=请输入要查询的月份(格式为2000年08月):
 if "%var:~4,1%%var:~7,1%"=="年月" goto year
 cls
 echo.&echo.&echo.&echo.&echo.
 echo     输入格式不正确!请返回正确输入。&ping /n 3 127.1>nul&goto begin
 :year
 set year=%var:~,4%
 set /a str=(%year%-1904)/4&set /a str1=%year%-1904
 set /a a=%str1%-%str%*4
 set str1=
 :month
 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%)
 if %month% equ 2 set n=28
 if %a% equ 0 set n=29
 for %%i in (1,3,5,7,8,10,12) do if "%%i"=="%month%" set n=31
 for %%i in (4,6,9,11) do if "%%i"=="%month%" set n=30
 set /a month=%month%-1
 if %month% equ 0 set /a number2=0
 if %month% equ 1 set /a number2=31
 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
 if %month% lss 2 set /a number2=%number2%-1
 :day
 cls
 echo.&echo.&echo.&echo.&echo.
 echo
 echo.
 for /l %%i in (1,1,%n%) do (
 set day=%%i
 call :week %%day%%
 )
 echo.&echo    本次查询完成,继续查询请按任意键,退出请关闭窗口。
 pause>nul&goto begin
 :week
 set /a w+=1
 set /a number=%number1%+%number2%+%1-1
 set /a week=%number%/7
 set /a b=%number%-%week%*7
 set day=%day%日
 call,set day=%day: =%
 if not "%day:~2,1%"=="日" set day= %day%
 set code=五六天一二三四
 call,set code=星期%%code:~%b%,1%%
 set str1=%str1%    %day%
 set str2=%str2%  %code%
 set /a v+=1&set /a m+=1
 if %v% gtr 7 set str2=--------------------------------------------------------
 if %m% gtr 6 set m=0&echo     ^|%str2%^|&echo     ^|%str1%^|&set str1=&set str2=
 if %w% gtr 28 set str3=%str3%    %day%
 if %w% equ %n% echo     ^|%str2%^|&echo     ^|%str3%&echo     ^|%str2%^|
 goto :eof
 
 Last edited by zw19750516 on 2008-4-20 at 09:40 AM ]
 
 
 | 此帖被 +7 点积分        点击查看详情 | 评分人:【 plp626 】 | 分数: +6 | 时间:2008-4-7 23:41 |  | 评分人:【 gggqqv 】 | 分数: +1 | 时间:2008-4-8 09:44 | 
 | 
 
 
 
 
 |  
                  |  批处理之家新域名:www.bathome.net
 |  | 
|  2008-4-7 00:48 |  | 
|  | 
 
| terse 银牌会员
 
      
 
 
 
 积分 2404
 发帖 946
 注册 2005-9-8
 状态 离线
 |  | 
|  2008-4-7 01:10 |  | 
|  | 
 
| HAT 版主
 
         
 
 
 
 积分 9023
 发帖 5017
 注册 2007-5-31
 状态 离线
 | 
| 『第 3 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
不是有高人发帖说过吗?农历是天文学家根据历法推算出来的,没有现成的程序算法。就用2楼给的数据吧。 
 
 
 
 |  | 
|  2008-4-7 06:23 |  | 
|  | 
 
| bat-zw 金牌会员
 
       永远的学习者
 
 
 积分 3105
 发帖 1276
 注册 2008-3-8
 状态 离线
 | 
| 『第 4 楼』:
 再次加强(加入本月本日显示):
 
使用 LLM 解释/回答一下 
 
 
再加入窗口颜色变化并加入注解: @echo off&mode con cols=65 lines=20rem: 设置窗口标题
 title 批处理版万年历
 :begin
 rem: 设置窗口随机颜色
 set /a P=%random%%%15
 if %p% equ 10 set p=a
 if %p% equ 11 set p=b
 if %p% equ 12 set p=c
 if %p% equ 13 set p=d
 if %p% equ 14 set p=e
 color %p%f
 cls
 echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
 rem: 清空置0
 set var=&set str=&set str1=&set str2=&set str3=&set n=0&set m=0&set v=0&set w=0
 rem: 提取系统当日日期参数
 set var=%date:~,4%年%date:~5,2%月
 set /p var=输入要查询的月份(格式为2000年08月默认回车为本月):
 rem: 判断输入格式
 if "%var:~4,1%%var:~7,1%"=="年月" goto year
 cls
 echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
 echo            输入格式不正确!请返回正确输入。&ping /n 2 127.1>nul&goto begin
 :year
 rem: 提取输入的年份参数
 set year=%var:~,4%
 rem: 以四年为周期计算年余数
 set /a str=(%year%-1904)/4&set /a str1=%year%-1904
 set /a a=%str1%-%str%*4
 set str1=
 rem: 计算整年天数
 if %a% equ 0 (set /a number1=%str%*1461) else (set /a number1=%str%*1461+%a%*365+1)
 :month
 rem: 提取输入的月份参数
 if %var:~5,1% equ 0 (set month=%var:~6,1%) else (set month=%var:~5,2%)
 rem: 计算输入月份的天数
 if %month% equ 2 set n=28
 if %a% equ 0 set n=29
 for %%i in (1,3,5,7,8,10,12) do if "%%i"=="%month%" set n=31
 for %%i in (4,6,9,11) do if "%%i"=="%month%" set n=30
 set /a month=%month%-1
 rem: 计算整月天数
 if %month% equ 0 set /a number2=0
 if %month% equ 1 set /a number2=31
 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
 if %month% lss 2 set /a number2=%number2%-1
 set str=
 :day
 cls
 echo.&echo.&echo.&echo.&echo.
 echo
 echo.
 rem: 以当月天数为循环
 for /l %%i in (1,1,%n%) do (
 set day=%%i
 call :week %%day%%
 )
 echo.&echo    本次查询完成,继续查询请按任意键,退出请关闭窗口。
 pause>nul&goto begin
 :week
 set /a v+=1&set /a m+=1
 rem: 计算总天数
 set /a number=%number1%+%number2%+%1-1
 rem: 计算总星期数
 set /a week=%number%/7
 rem: 计算星期的余数
 set /a b=%number%-%week%*7
 if %day% lss 10 (set today=0%day%) else (set today=%day%)
 set day=%day%日
 call,set day=%day: =%
 if not "%day:~2,1%"=="日" set day= %day%
 rem: 判断如是本月刚将本日显示为五角星
 if "%var:~,4%%var:~5,2%%today:~,2%"=="%date:~,4%%date:~5,2%%date:~8,2%" set day=   ★
 rem: 根据星期余数推算为星期几
 set code=五六天一二三四
 call,set code=星期%%code:~%b%,1%%
 rem: 变量累加(不输出)
 set str=%str%    %day%
 set str1=%str1%  %code%
 rem: 设置输出条件并及时清空变量
 if %v% gtr 7 set str1=
 if %m% equ 7 set m=0&echo   %str1%&echo   %str%&set str=&set str1=
 if %v% gtr 28 set str2=%str2%    %day%
 if %v% equ %n% echo   %str1%&echo   %str2%&echo   %str1%&set str1=&set str2=
 goto :eof
 
 Last edited by zw19750516 on 2008-4-8 at 06:34 PM ]
 
 
 
 
 |  
                  |  批处理之家新域名:www.bathome.net
 |  | 
|  2008-4-7 23:16 |  | 
|  | 
 
| abcd 银牌会员
 
      
 
 
 
 积分 1436
 发帖 739
 注册 2007-10-11
 状态 离线
 | 
| 『第 5 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
'--]' 不是内部或外部命令,也不是可运行的程序或批处理文件。
 '--]' 不是内部或外部命令,也不是可运行的程序
 或批处理文件。
 '--]' 不是内部或外部命令,也不是可运行的程序
 或批处理文件。
 
直接回车 
 
 
 
 |  | 
|  2008-4-7 23:21 |  | 
|  | 
 
| abcd 银牌会员
 
      
 
 
 
 积分 1436
 发帖 739
 注册 2007-10-11
 状态 离线
 |  | 
|  2008-4-7 23:23 |  | 
|  | 
 
| plp626 银牌会员
 
      钻石会员
 
 
 积分 2278
 发帖 1020
 注册 2007-11-19
 状态 离线
 |  | 
|  2008-4-7 23:42 |  | 
|  | 
 
| xb2008chopin 初级用户
 
   
 
 
 
 积分 24
 发帖 11
 注册 2008-4-6
 状态 离线
 |  | 
|  2008-4-8 03:11 |  | 
|  | 
 
| bat-zw 金牌会员
 
       永远的学习者
 
 
 积分 3105
 发帖 1276
 注册 2008-3-8
 状态 离线
 |  | 
|  2008-4-8 09:06 |  | 
|  | 
 
| BWSkyer 中级用户
 
    我是DOS学者
 
 
 积分 367
 发帖 180
 注册 2006-5-14
 来自 重庆
 状态 离线
 |  | 
|  2008-4-8 10:19 |  | 
|  | 
 
| bat-zw 金牌会员
 
       永远的学习者
 
 
 积分 3105
 发帖 1276
 注册 2008-3-8
 状态 离线
 | 
| 『第 11 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Originally posted by BWSkyer at 2008-4-8 10:19:后面一个加强的,输入月份后查询不了, 代码我现在还有部分都看不懂
 
输入格式为****年0*月,只输入*月是不行的,不会被认定为正确输入。 
 
 
 
 
 |  
                  |  批处理之家新域名:www.bathome.net
 |  | 
|  2008-4-8 13:18 |  | 
|  | 
 
| bat-zw 金牌会员
 
       永远的学习者
 
 
 积分 3105
 发帖 1276
 注册 2008-3-8
 状态 离线
 | 
| 『第 12 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Originally posted by abcd at 2008-4-7 23:23:输入格式太不灵活了
 
 建议多几种输入格式吧
 
这样输入是为了计算中的认定的,随意输入将会导致计算过程出错。 
 
 
 
 
 |  
                  |  批处理之家新域名:www.bathome.net
 |  | 
|  2008-4-8 13:18 |  | 
|  | 
 
| BWSkyer 中级用户
 
    我是DOS学者
 
 
 积分 367
 发帖 180
 注册 2006-5-14
 来自 重庆
 状态 离线
 |  | 
|  2008-4-8 13:23 |  | 
|  | 
 
| bat-zw 金牌会员
 
       永远的学习者
 
 
 积分 3105
 发帖 1276
 注册 2008-3-8
 状态 离线
 | 
| 『第 14 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Originally posted by BWSkyer at 2008-4-8 13:23:我是这样输入的哦~~~~
 
满10位前面就不要加0了。 
不知兄弟哪段看不懂,我可以解释下。
 
 Last edited by zw19750516 on 2008-4-8 at 02:02 PM ] 
 
 
 
 
 |  
                  |  批处理之家新域名:www.bathome.net
 |  | 
|  2008-4-8 13:55 |  | 
|  | 
 
| bat-zw 金牌会员
 
       永远的学习者
 
 
 积分 3105
 发帖 1276
 注册 2008-3-8
 状态 离线
 | 
|    『第 15 楼』:
 根据日常习惯再次修改(星期天显示在前):
 
使用 LLM 解释/回答一下 
 
 
----------------------------------- 
继续修正了闰年月计算的错误以及当月1号为星期天首行排版不齐的问题,同时去除与亮白色字体不协调的窗口颜色。 
----------------------------------- 
于2008年4月20日再次简化代码和提高输入灵活性。
 @@echo off&color 4f&mode con cols=65 lines=22title 批处理版万年历
 :begin
 set /a P=%random%%%14
 for %%i in (6,7,10,11,12) do if %%i equ %p% goto begin
 if %p% equ 13 set p=d
 color %p%f
 cls
 echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
 set var=&set str=&set str1=&set n=0&set m=0&set number2=0
 set var=%date:~,7%
 set /p var=输入要查询的月份(格式为2000-08默认回车为本月):
 set /a month=100%var:~5%%%100
 if "%var:~4,1%"=="-" if %month% leq 12 goto year
 cls
 echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
 echo            输入格式不正确!请返回正确输入。&ping /n 2 127.1>nul&goto begin
 :year
 set year=%var:~,4%
 set /a str=(%year%-1904)/4,a=(%year%-1904)%%4
 :month
 if %a% equ 0 (set /a number1=%str%*1461) else (set /a number1=%str%*1461+%a%*365+1)
 if %month% equ 2 (
 if %a% equ 0 (
 set n=29
 ) else (
 set n=28
 )
 )
 for %%i in (1,3,5,7,8,10,12) do if %%i equ %month% set n=31
 for %%i in (4,6,9,11) do if %%i equ %month% set n=30
 set /a month-=1
 if %month% gtr 0 for /l %%a in (1,1,%month%) do call :loop %%a
 if %month% gtr 2 (
 if %a% equ 0 (
 set /a number2+=29
 ) else (
 set /a number2+=28
 )
 )
 set str=
 set /a month+=1
 if %month% lss 10 set month=0%month%
 :day
 cls
 echo.&echo.&echo.&echo.&echo.
 echo
 set list=星期天  星期一  星期二  星期三  星期四  星期五  星期六
 echo.
 echo      %list%
 for /l %%i in (1,1,37) do (
 set day=%%i
 call :week %%day%%
 )
 echo.&echo    本次查询完成,继续查询请按任意键,退出请关闭窗口。
 pause>nul&goto begin
 :week
 set /a m+=1 ,number=%number1%+%number2%+%1-1
 set /a b=%number%%%7
 if %day% lss 10 (set today=0%day%) else (set today=%day%)
 set day=%day%日
 call,set day=%day: =%
 if not "%day:~2,1%"=="日" set day= %day%
 if "%var:~,4%%var:~5,2%%today:~,2%"=="%date:~,4%%date:~5,2%%date:~8,2%" set day=  ★
 set code=五六天一二三四
 call,set code=星期%%code:~%b%,1%%
 set /a c=%b%+5
 if %c% gtr 7 set /a c-=7
 set str=%str%    %day%
 if %m% lss 2 for /l %%i in (1,1,%c%) do call :lp
 set str1=
 if %m% lss %n% if "%code%"=="星期六" echo    %str1%&echo   %str%&set str=
 if %m% equ %n% echo    %str1%&echo   %str%&echo    %str1%&set str=
 goto :eof
 :loop
 for %%i in (1,3,5,7,8,10) do if %%i equ %1 set /a number2+=31
 for %%i in (4,6,9,11) do if %%i equ %1 set /a number2+=30
 goto :eof
 :lp
 if not "%code%"=="星期天" set str=        %str%
 
 Last edited by zw19750516 on 2008-4-20 at 09:21 AM ]
 
 
 
 
 
 
 |  
                  |  批处理之家新域名:www.bathome.net
 |  | 
|  2008-4-9 01:36 |  |