中国DOS联盟论坛

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-10 03:33
47,811 topics / 349,897 posts / today 2 new / 48,255 members
DOS批处理 & 脚本技术(批处理室) » [Give up, do not enter]About backtracking to any time
Printable Version  2,433 / 32
Floor1 bat-zw Posted 2008-06-01 21:58
金牌会员 Posts 1,276 Credits 3,105
&&Because of a brother's help request, I suddenly thought of writing a batch script (not using VBS) for arbitrary time backtracking. Because I knew that judging the time points of hours, minutes, days, months, and years would be quite complicated, I was mentally prepared at the beginning, but only when I was in the middle of writing did I really understand the difficulties here. The difficulty lies in how to convert and calculate the arbitrary time entered by others. For example, if you enter 0 0 0 0 100000 (meaning 100,000 minutes), how to convert it into the year, month, day, hour, and minute to backtrack. I racked my brains and still couldn't figure it out clearly. I hope everyone can sort out the ideas. Because the meaning of the problem is also difficult to describe clearly, I specially post my partial code below:


[ Last edited by zw19750516 on 2008-6-2 at 12:39 AM ]
Floor2 bat-zw Posted 2008-06-01 22:17
金牌会员 Posts 1,276 Credits 3,105
Floor3 plp626 Posted 2008-06-01 22:20
银牌会员 Posts 1,020 Credits 2,278
My algorithm for this kind of problem is: first convert any given date into minutes (and if needed, also convert to seconds, hours, days), and then convert the minutes back into a date. You can refer to the functions in the function library --- timediff
Floor4 26933062 Posted 2008-06-01 22:23
银牌会员 Posts 879 Credits 2,268
In fact, there are classic codes in the forum for backtracking days. Just judge the number of days in the time part.
Floor5 bat-zw Posted 2008-06-01 22:28
金牌会员 Posts 1,276 Credits 3,105
Brothers, is it too simple? I've read all the forum-related posts and also discussed with namejm on QQ.
Floor6 bat-zw Posted 2008-06-01 22:32
金牌会员 Posts 1,276 Credits 3,105
In fact, my original intention was to write a batch processing program for arbitrary time backtracking. As long as others input any set of five values in the input format of year, month, day, hour, and minute, they can get the backtracked year, month, day, hour, and minute. For example, input 0 0 0 100000 0 (100000 hours).
Floor7 HAT Posted 2008-06-01 22:35
版主 Posts 5,017 Credits 9,023
Request zw19750516 brother to disclose his QQ number and namejm's QQ number ^_^
Floor8 26933062 Posted 2008-06-01 22:37
银牌会员 Posts 879 Credits 2,268
Provide an idea: First, convert the month, day, and time into the number of days. Then subtract the input year from the current year. Then subtract the converted number of days from the result. Finally, refine the time precisely.
Floor9 bat-zw Posted 2008-06-01 22:52
金牌会员 Posts 1,276 Credits 3,105
Originally posted by 26933062 at 2008-6-1 22:37:
Provide an idea
First, convert the month, day, time into days.
Then subtract the input year from the current year,
Then subtract the converted days from the result, and finally refine the time.

Thanks for your concern many times, brother. Please look at this set of values 20 34 600 4000 10000, going back 20 years, 34 months, 600 days, 4000 hours, 10000 minutes. I have an idea that is to calculate the time difference from the current system time to January 1, 00:00 of the first year of the AD as the number of minutes, then convert all the input time into the value counted in minutes, then subtract the input converted value from the system value, and then push forward the year, month, day, hour, minute from the reference value of January 1, 00:00 of the first year of the AD. The problem is that it is quite difficult to convert the input value into minutes. For example, how many minutes is 20 years =? and 34 months =?
Floor10 slore Posted 2008-06-01 22:55
铂金会员 Posts 2,478 Credits 5,212
Passing by...

Still VBS is refreshing~~
Floor11 bat-zw Posted 2008-06-01 23:00
金牌会员 Posts 1,276 Credits 3,105
It really feels so difficult. Could it really be that batch processing can't solve this problem?
Floor12 terse Posted 2008-06-01 23:05
银牌会员 Posts 946 Credits 2,404
Will it overflow
Also, why do I always get an error when running the above
What is the role of this P
Floor13 26933062 Posted 2008-06-01 23:11
银牌会员 Posts 879 Credits 2,268
If all are converted into minutes, it will be an extremely large number, and then it involves the problem of large number calculation.

In addition, there is another question: 20 years, 2 months, 600 days, 4000 hours, 10000 minutes

As above, what does 2 months refer to? For example, if today is June 1st, is 2 months ago April 1st?

Or 2 months after the current time minus 600 days, 4000 hours, 10000 minutes?
Floor14 bat-zw Posted 2008-06-01 23:18
金牌会员 Posts 1,276 Credits 3,105
Originally posted by 26933062 at 2008-6-1 23:11:
If all are converted to minutes, it will be an extremely large number, which then involves the problem of large number calculation.
In addition, there is another question: 20 years, 2 months, 600 days, 4000 hours, 10000 minutes
As above, what does 2 months refer to...

The five values 20, 34, 600, 4000, 10000 are all to be deduced through calculation, not simply subtraction of the same phase
Floor15 moniuming Posted 2008-06-01 23:19
银牌会员 Posts 574 Credits 1,335 From 广西
If all are converted into minutes, it will be an extremely large number, which then involves the problem of large number calculation.
In addition, there is another question: 20 years, 2 months, 600 days, 4000 hours, 10000 minutes
As above, what does 2 months refer to? For example, if today is June 1st, is 2 months ago April 1st?
Or is it 2 months after subtracting 600 days, 4000 hours, and 10000 minutes from the current time?

I think the building owner means: 20 years + 2 months + 600 days + 4000 hours + 10000 minutes

But it feels meaningless, and even............. alas
1 2 3  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023