中国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-09-29 08:02
47,813 topics / 349,918 posts / today 0 new / 48,278 members
DOS批处理 & 脚本技术(批处理室) » [Give up, do not enter]About backtracking to any time
Printable Version  2,796 / 32
Floor16 bat-zw Posted 2008-06-01 23:22
金牌会员 Posts 1,276 Credits 3,105
Originally posted by moniuming at 2008-6-1 23:19:

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

But it feels meaningless, and even............. Alas

It's not meaningless. The motivation for me to write this batch script is to make it convenient for everyone to trace back time.
Floor17 26933062 Posted 2008-06-01 23:23
银牌会员 Posts 879 Credits 2,268
20 years 2 months 600 days 4000 hours 10000 minutes
Let's put it this way
Subtract 10000 minutes from the current time first, then subtract 4000 hours, then subtract 600 days.
Suppose the result at this time is March 20, 2005, 19:20. Then how to subtract 2 months at this time?
Is the result January 20, 2005, 19:20?
Floor18 terse Posted 2008-06-01 23:26
银牌会员 Posts 946 Credits 2,404
If it's just like this, it's still manageable to estimate. The following is for calculating the number of days. It should be no problem to add handling for hours and minutes.
Floor19 bat-zw Posted 2008-06-01 23:28
金牌会员 Posts 1,276 Credits 3,105
Originally posted by 26933062 at 2008-6-1 23:23:
20 years 2 months 600 days 4000 hours 10000 minutes
Let me put it this way
First subtract 10,000 minutes from the current time, then subtract 4,000 hours, then subtract 600 days,
Assuming the result at this time is March 20, 2005 19:20, then this...

Brother, your thinking is deviated. In the end, there will not be exactly two months subtracted. Instead, you should convert and calculate the previous ones first, then decrement from minutes all the way to years

[ Last edited by zw19750516 on 2008-6-1 at 11:30 PM ]
Floor20 bat-zw Posted 2008-06-01 23:36
金牌会员 Posts 1,276 Credits 3,105
Originally posted by terse at 2008-6-1 23:26:
If it's just like this, it's estimated to be manageable.
The following is to calculate the number of days. Adding the processing of hours and minutes should be no problem.
Floor21 terse Posted 2008-06-01 23:45
银牌会员 Posts 946 Credits 2,404
Originally posted by zw19750516 at 2008-6-1 23:36:

Dude, you should still remember a few threads I posted before about date calculations, right? Please believe that I'm okay with such algorithms. What I need to solve now is the problem of converting arbitrary times.

How exactly is it converting arbitrary times? I'm a bit slow-witted, hope you can explain it to me.
Floor22 bat-zw Posted 2008-06-01 23:53
金牌会员 Posts 1,276 Credits 3,105
Originally posted by terse at 2008-6-1 23:45:

How to convert any time? I'm sorry I'm stupid, please brother explain it to me.

Oh, I've discussed this for such a long time before, but brother still doesn't understand what I mean. It's also my fault for not explaining clearly.
For example, when entering 20 38 67 900 30000 at the batch processing prompt for time backtracking, going back 20 years + 38 months + 67 days + 900 hours + 30000 minutes from the current time is? years? months? days? hours? minutes.
First, convert minutes to whole hours a + remainder, then convert hours + a to whole months b + remainder (here is stuck), then convert months + b to whole years c + remainder, then add years + c, and then I can't think clearly...

[ Last edited by zw19750516 on 2008-6-1 at 11:59 PM ]
Floor23 26933062 Posted 2008-06-01 23:55
银牌会员 Posts 879 Credits 2,268
I really can't understand the problem. For 20 years or 2 months, there must always be a specific number of days! Then there must be the phenomenon I mentioned on the 17th floor.
Floor24 bat-zw Posted 2008-06-02 00:03
金牌会员 Posts 1,276 Credits 3,105
Originally posted by 26933062 at 2008-6-1 23:55:
I really can't understand the problem.
For 20 years or 2 months, there must be a specific number of days. Then there must be the phenomenon I mentioned on floor 17.

The number of days is definitely there. On the time coordinate, the point in time that goes back 20 years + 39 months + 470 days + 6000 hours + 10001 minutes from the current time must exist. The problem is how we can find this point in time. This will involve a series of judgments and conversion calculations.
ps: Brother, won't you also think I'm an alien, hehe.

[ Last edited by zw19750516 on 2008-6-2 at 12:05 AM ]
Floor25 terse Posted 2008-06-02 00:17
银牌会员 Posts 946 Credits 2,404
So it seems that there should be a reason for the order, because there are intercalary months, isn't that right?
Floor26 bat-zw Posted 2008-06-02 00:21
金牌会员 Posts 1,276 Credits 3,105
Originally posted by terse at 2008-6-2 00:17:
In this case, there should be a rule for the order. Because there is a leap month, right?

It's said that the order is minute-hour-day-month-year. It's so difficult because of the problem of leap months and the different number of days in each month!!!
Floor27 26933062 Posted 2008-06-02 00:24
银牌会员 Posts 879 Credits 2,268
Okay, let's do this step by step. First, the current time is April 2, 2008, 20:10. We need to go back 2 months, 1 day, 1 hour, and 1 minute.

First, subtract 2 months from April 2008. April minus 2 months is February 2008. But wait, we need to be careful with the days. February 2008 has 29 days because 2008 is a leap year.

Now, start with April 2, 20:10. Subtract 1 day first: April 2, 20:10 minus 1 day is March 31, 20:10. Then subtract 2 months from March 31, 20:10. March minus 2 months is January 31, 20:10. Now subtract 1 hour: January 31, 20:10 minus 1 hour is January 31, 19:10. Then subtract 1 minute: January 31, 19:10 minus 1 minute is January 31, 19:09. Wait, no, that's not right. Wait, I made a mistake. Let's start over.

Current date: April 2, 2008, 20:10.

Step 1: Subtract 2 months. April - 2 months = February. But February 2008 has 29 days. So April 2 - 2 months = February 2, 20:10. Then subtract 1 day: February 2 - 1 day = January 31, 20:10. Then subtract 1 hour: January 31, 20:10 - 1 hour = January 31, 19:10. Then subtract 1 minute: January 31, 19:10 - 1 minute = January 31, 19:09. Wait, that can't be right. Wait, I messed up the month subtraction. Let's do it properly.

Current date: 2008-04-02 20:10:00

Subtract 2 months: 2008-04-02 minus 2 months is 2008-02-02 20:10:00

Then subtract 1 day: 2008-02-02 minus 1 day is 2008-02-01 20:10:00

Then subtract 1 hour: 2008-02-01 20:10:00 minus 1 hour is 2008-02-01 19:10:00

Then subtract 1 minute: 2008-02-01 19:10:00 minus 1 minute is 2008-02-01 19:09:00

Wait, no, I made a mistake here. Wait, April minus 2 months is February, but February 2008 has 29 days. So April 2nd minus 2 months is February 2nd. Then February 2nd minus 1 day is January 31st. Then January 31st 20:10 minus 1 hour is January 31st 19:10, minus 1 minute is January 31st 19:09. But wait, let's check again.

Wait, let's use a different approach. Let's convert the current time to total minutes since a certain point, then subtract the total minutes for 2 months, 1 day, 1 hour, 1 minute, then convert back.

Current time: April 2, 2008, 20:10. Let's calculate total minutes from, say, January 1, 2000, but that's complicated. Alternatively, calculate day by day.

April has 30 days, March has 31, February 2008 has 29, January has 31.

Current date: April 2, 2008. So from January 1, 2008 to April 2, 2008: January has 31 days, February 29, March 31, April 2. Total days: 31 + 29 + 31 + 2 = 93 days. Total minutes: 93 days * 24 hours/day * 60 minutes/hour + 20 hours * 60 + 10 = 93*1440 + 1200 + 10 = 133920 + 1210 = 135130 minutes.

Now, we need to subtract 2 months, 1 day, 1 hour, 1 minute.

2 months: Let's take January and February. January has 31 days, February 29. So 2 months is 31 + 29 = 60 days. Then subtract 1 day: 60 - 1 = 59 days. Then subtract 1 hour: 59 days is 59*24 = 1416 hours, minus 1 hour is 1415 hours. Then subtract 1 minute: 1415 hours is 1415*60 = 84900 minutes, minus 1 minute is 84899 minutes.

Now, subtract 84899 minutes from 135130 minutes: 135130 - 84899 = 50231 minutes.

Now, convert 50231 minutes back to days, hours, minutes.

50231 minutes / (24*60) = 50231 / 1440 = 34 days with a remainder. 34*1440 = 48960. 50231 - 48960 = 1271 minutes.

1271 minutes / 60 = 21 hours with a remainder. 21*60 = 1260. 1271 - 1260 = 11 minutes.

Now, find the date. Starting from January 1, 2008, add 34 days. January has 31 days, so 34 days from January 1 is January 1 + 34 days = February 4? Wait, no. Wait, I made a mistake in the direction. Wait, we subtracted time, so we need to go back.

Wait, I think I messed up the total minutes calculation. Let's start over correctly.

Current date and time: 2008-04-02 20:10:00

We need to subtract 2 months, 1 day, 1 hour, 1 minute.

Step 1: Subtract 2 months. April - 2 months = February. So date becomes 2008-02-02 20:10:00

Step 2: Subtract 1 day. 2008-02-02 - 1 day = 2008-02-01 20:10:00

Step 3: Subtract 1 hour. 2008-02-01 20:10:00 - 1 hour = 2008-02-01 19:10:00

Step 4: Subtract 1 minute. 2008-02-01 19:10:00 - 1 minute = 2008-02-01 19:09:00

Wait, but let's check with another method. Let's use months with 30 days for simplicity, but adjust for leap years.

April 2, 20:10 minus 2 months is February 2, 20:10. Then February 2 minus 1 day is January 31, 20:10. Then January 31, 20:10 minus 1 hour is January 31, 19:10. Then January 31, 19:10 minus 1 minute is January 31, 19:09. Hmm, but wait, February 2008 has 29 days, so April 2 minus 2 months is February 2, which is correct. Then February 2 minus 1 day is January 31, correct. Then January 31, 20:10 minus 1 hour is 19:10, minus 1 minute is 19:09. So the result should be January 31, 2008, 19:09.Wait, no, I think I made a mistake in the month subtraction. Let's do it month by month correctly.

Current month: April. Subtract 2 months: April - 2 = February. So the date is February 2, 20:10. Then subtract 1 day: February 2 - 1 = January 31, 20:10. Then subtract 1 hour: January 31, 20:10 - 1 = January 31, 19:10. Then subtract 1 minute: January 31, 19:10 - 1 = January 31, 19:09. Yes, that's correct. So the time 2 months, 1 day, 1 hour, 1 minute before April 2, 2008 20:10 is January 31, 2008 19:09.
Floor28 bat-zw Posted 2008-06-02 00:30
金牌会员 Posts 1,276 Credits 3,105
9:19 on January 1, 2008, this is easy to calculate, but the following is not easy:
20:10 on April 20, 2008 minus 2 months, 48 days, 29 hours, 78 minutes
Floor29 bat-zw Posted 2008-06-02 00:37
金牌会员 Posts 1,276 Credits 3,105
Forget it, maybe I really overcomplicated things (in fact, there's no such thing as 39 months, 500 days, 6,000 hours, 10,00able minutes like 20 years ago). I have to work tomorrow, so I'll go to sleep first. Thanks, brothers.
Floor30 26933062 Posted 2008-06-02 00:43
银牌会员 Posts 879 Credits 2,268
Originally posted by zw19750516 at 2008-6-2 00:30:
9 minutes 19 hours 1 day February 2008, this is easy to calculate, but the following is not easy to calculate:


[ Last edited by zw19750516 on 2008-6-2 at 12:31 AM ]

Is this not just subtracting 2 full months?
First subtract the minutes, hours, days, and the result is: 9 minutes 19 hours April 1, 2008
Then subtract 2 full months, that is: 4 minus 2 gives 9 minutes 19 hours February 1, 2008
Prev  1 2 3  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023