![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-08 17:40 |
47,811 topics / 349,895 posts / today 0 new / 48,253 members |
| DOS批处理 & 脚本技术(批处理室) » Batch version perpetual calendar |
| Printable Version 16,655 / 44 |
| Floor1 zjl5 | Posted 2007-05-26 20:43 |
| 初级用户 Posts 15 Credits 82 | |
|
────────── 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 ] |
|
| Floor2 lxmxn | Posted 2007-05-26 20:51 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Not bad. If you add a function to judge leap years, it will be even more perfect.
|
|
| Floor3 ieutk | Posted 2007-05-27 14:30 |
| 初级用户 Posts 48 Credits 107 | |
|
It would be even better if it could check the lunar calendar too! Ha~
|
|
| Floor4 qzwqzw | Posted 2007-05-27 15:12 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
I tried it
Aside from 31-day months like 2006-12 showing 30 days all the other months show 31 days The problem is in these lines Still needs more work |
|
| Floor5 my3439955 | Posted 2007-05-27 16:13 |
| 中级用户 Posts 99 Credits 272 | |
|
This calendar is also pretty good
http://www.cn-dos.net/forum/viewthread.php?tid=27739&fpage=11 It can also support any year including leap years http://www.cn-dos.net/forum/viewthread.php?tid=27739&page=2#pid195566 [ Last edited by my3439955 on 2007-5-27 at 04:20 PM ] |
|
| Floor6 my3439955 | Posted 2007-05-27 16:23 |
| 中级用户 Posts 99 Credits 272 | |
Originally posted by ieutk at 2007-5-27 14:30: There is no regular formula for the lunar calendar; you can only calculate a certain span of time and then use a lookup table If you don't believe it, look at those perpetual calendars that support the lunar calendar Support for the lunar calendar generally will not exceed 200 years For the Gregorian calendar there is no such limitation You can go to any year |
|
| Floor7 zjl5 | Posted 2007-05-27 17:45 |
| 初级用户 Posts 15 Credits 82 | |
Originally posted by qzwqzw at 2007-5-27 03:12 PM: |
|
| Floor8 qzwqzw | Posted 2007-05-27 18:14 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
For the lunar calendar, maybe there is a way that doesn't require table lookup
My father told me that back in his hometown there was a fool Normally he was crazy and muddle-headed But he alone had mastered a "divine skill" that people really admired Namely, he had memorized the old imperial almanac for the past five hundred years Questions like big and small lunar months and leap months were no problem at all for him I never met the man, and to this day I don't know what method he used --------------------------------------------------------- From a rational point of view The lunar calendar used nowadays Although it was finalized only after revisions through many dynasties Ultimately still comes from the earliest Xia calendar And the revision and perfection of the Xia calendar mainly depended on achievements in astronomy Other than that, there ought to be a purely mathematical way to calculate and predict it [ Last edited by qzwqzw on 2007-5-27 at 06:17 PM ] |
|
| Floor9 zjl5 | Posted 2007-05-27 19:50 |
| 初级用户 Posts 15 Credits 82 | |
|
qzwqzw brother, I changed this middle section
to The results didn't improve much. The bigger problem seems to be in for /l %%i in (%w%,1,%cyc%) I really can't figure it out. Please help improve it. |
|
| Floor10 qzwqzw | Posted 2007-05-28 00:29 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
The main problem is that the weekday order calculated by the formula is not consistent with the weekday order shown in the calendar
The formula calculates with Monday as the start and Sunday as the end The calendar display is exactly the opposite The solution is very simple Just switch either the formula's weekday order or the calendar's display order To switch the formula's weekday order, just move that +1 inside the parentheses ------------------------------------ Also, the 2006-12 problem is solved You need to add one more display line and also add two more variables ------------------------------------- There are still some other problems For example, the bare variable in if %d% geq 32 And the leading-0 problem with variables m / d And then there's the issue of variable naming conventions --------------------------------------------- Below is my code |
|
| Floor11 zjl5 | Posted 2007-05-28 00:57 |
| 初级用户 Posts 15 Credits 82 | |
|
Thanks, now that's really perfect.
|
|
| Floor12 namejm | Posted 2007-06-02 23:38 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Based on the one on the 10th floor, I modified it a bit and got the following code. The changes in effect are as follows:
1. The positions of the dates are fixed, while the weekday sequence changes dynamically; 2. Dates below 10 do not have a leading 0; 3. If you enter today's date again, it will always display "Today" instead of "that day"; [ Last edited by namejm on 2007-6-2 at 11:50 PM ] |
|
| Floor13 qzwqzw | Posted 2007-06-03 00:07 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
This display method does not fit everyday habits
I guess it would be hard for people to accept If you don't want to use too many variables you can use for to output the dates in order As long as you control the timing of line breaks, there won't be any problem Also it would be best to control the range and format of the year At most you only need to enter a two-digit year 50~99 is judged as 19xx 00~49 is judged as 20xx There isn't much point in calculating weekdays too far away |
|
| Floor14 namejm | Posted 2007-06-03 00:15 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
The method of dynamically displaying the weekday sequence really doesn't quite fit common habits. I just thought it was interesting, so I adapted it a bit, hehe, just putting it out as a new effect.
As for the sentence "There isn't much point in calculating weekdays too far away," I'm not sure what exactly that refers to. I don't have too many thoughts on it for now, but if you have any interesting ideas, I'd like to hear them too ^_^. |
|
| Floor15 qzwqzw | Posted 2007-06-03 02:16 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
For example, the effect of the following code
|
|
| 1 2 3 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |