|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
Originally posted by moniuming at 2008-6-1 23:19:
我觉得楼主的意思是:20年+2个月+600天+4000个小时+10000分钟
但感觉没什么意义,甚至.............唉
这不是没意义,我写这个批处理动机就是为了让大家能方便的回溯时间。
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.
|

批处理之家新域名:www.bathome.net |
|
2008-6-1 23:22 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
20年2个月600天4000个小时10000分钟
这么说吧
当前时间先减去10000分钟、再减去4000个小时、再减去600天,
假设此时结果为 2005年3月20日19点20分 那么此时再减去2个月,该如何减?
结果是 2005年1月20日19点20分 吗?
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?
|

致精致简! |
|
2008-6-1 23:23 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
如果仅仅这样估计还好处理
下面是算天数的 加上处理小时和分应该没问题吧
@echo off
SET/p TT=你想知道多少天前的日期?
for /f "tokens=1-3 delims=-/\:. " %%i in ("%date%") do set /a p1=%%i,p2=100%%j%%100,p3=100%%k%%100
if %p3% gtr %TT% goto ppp
:nxt
set/a p2-=1
if %p2% equ 0 set/a p1-=1&&set p2=12
set/a PN2="!(p1%%4) & !(!(p1%%100)) | !(p1%%400)",PN2=28+PN2
for /f "tokens=%p2%" %%i in ("31 %pN2% 31 30 31 30 31 31 30 31 30 31") do set/a p3=%p3%+%%i
if %p3% leq %tt% goto nxt
:ppp
set/a p3=%p3%-%tt%
setlocal enabledelayedexpansion
for %%i in (p2 p3) do if !%%i! lss 10 set %%i=0!%%i!
echo %p1%年%p2%月%p3%日
pause&goto :eof
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.
@echo off
SET/p TT=你想知道多少天前的日期?
for /f "tokens=1-3 delims=-/\:. " %%i in ("%date%") do set /a p1=%%i,p2=100%%j%%100,p3=100%%k%%100
if %p3% gtr %TT% goto ppp
:nxt
set/a p2-=1
if %p2% equ 0 set/a p1-=1&&set p2=12
set/a PN2="!(p1%%4) & !(!(p1%%100)) | !(p1%%400)",PN2=28+PN2
for /f "tokens=%p2%" %%i in ("31 %pN2% 31 30 31 30 31 31 30 31 30 31") do set/a p3=%p3%+%%i
if %p3% leq %tt% goto nxt
:ppp
set/a p3=%p3%-%tt%
setlocal enabledelayedexpansion
for %%i in (p2 p3) do if !%%i! lss 10 set %%i=0!%%i!
echo %p1%年%p2%月%p3%日
pause&goto :eof
|

简单!简单!再简单! |
|
2008-6-1 23:26 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-6-1 23:23:
20年2个月600天4000个小时10000分钟
这么说吧
当前时间先减去10000分钟、再减去4000个小时、再减去600天,
假设此时结果为 2005年3月20日19点20分 那么此 ...
兄弟思路出偏差了,最后根本不会存在整减两个月,而应是将前面的先转换运算,然后从分一路递减到年
Last edited by zw19750516 on 2008-6-1 at 11:30 PM ]
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 ]
|

批处理之家新域名:www.bathome.net |
|
2008-6-1 23:28 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
Originally posted by terse at 2008-6-1 23:26:
如果仅仅这样估计还好处理
下面是算天数的 加上处理小时和分应该没问题吧
@echo off
SET/p TT=你想知道多少天前的日期?
for /f "tokens=1-3 delim ...
老兄应该还记得我以前发的几个关于日期计算的贴子吧,请相信我对这样的算法还是没问题的,我现在要解决的是换算任意时间的问题。
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.
@echo off
SET/p TT=你想知道多少天前的日期?
for /f "tokens=1-3 delim ...
Dude, you should still remember the few posts I made before about date calculation. Please believe that I have no problem with such algorithms. What I need to solve now is the problem of converting any time.
|

批处理之家新域名:www.bathome.net |
|
2008-6-1 23:36 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
Originally posted by zw19750516 at 2008-6-1 23:36:
老兄应该还记得我以前发的几个关于日期计算的贴子吧,请相信我对这样的算法还是没问题的,我现在要解决的是换算任意时间的问题。
怎么个换算任意时间 恕小弟愚笨 望兄来解说一下
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.
|

简单!简单!再简单! |
|
2008-6-1 23:45 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
Originally posted by terse at 2008-6-1 23:45:
怎么个换算任意时间 恕小弟愚笨 望兄来解说一下
晕,前面都讨论了这么久了,兄弟还没明白我的意思啊,也只怪我没说明白。
如在时间回溯批处理提示输入处输入:20 38 67 900 30000,从当前时间向前
回溯20年+38个月+67天+900个小时+30000分钟是?年?月?日?时?分。
首选要将分换算成整时a+余数,再将时+a后换算成整月b+余数(在这果就卡壳
了),再将月+b后换算成整年c+余数,再将年+c,然后更想不清楚了。。。
Last edited by zw19750516 on 2008-6-1 at 11:59 PM ]
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 ]
|

批处理之家新域名:www.bathome.net |
|
2008-6-1 23:53 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
确实理解不了题意了。
20年或2个月,始终都必须有个具体天数才对啊?那么就必然存在我17楼说的现象。
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.
|

致精致简! |
|
2008-6-1 23:55 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-6-1 23:55:
确实理解不了题意了。
20年或2个月,始终都必须有个具体天数才对啊?那么就必然存在我17楼说的现象。
天数是肯定有的,在时间坐标上从当前时间向前回溯20年+39个月+470天+6000
个小时+10001分钟这个时间点肯定是存在的,问题是我们怎么去找到这个时间
点,这里面就将涉及到一系列的判断和转换运算了。
ps:兄弟不会也觉得我是个外星人吧,呵呵。
Last edited by zw19750516 on 2008-6-2 at 12:05 AM ]
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 ]
|

批处理之家新域名:www.bathome.net |
|
2008-6-2 00:03 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
这样看来 次序应该也有说法 因为有闰 是不是呢?
So it seems that there should be a reason for the order, because there are intercalary months, isn't that right?
|

简单!简单!再简单! |
|
2008-6-2 00:17 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 26 楼』:
使用 LLM 解释/回答一下
Originally posted by terse at 2008-6-2 00:17:
这样看来 次序应该也有说法 因为有闰 是不是呢?
说了次序是分-时-天-月-年,就是因为闰的问题还有每月天数不同的问题才会这么
难!!!
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!!!
|

批处理之家新域名:www.bathome.net |
|
2008-6-2 00:21 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
假设当前时间是 2008年4月2日20点10分
问: 2个月前1天1小时1分钟 是什么时间,你用手工计算告诉我答案吧、
然后说说你的计算过程。
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.
|

致精致简! |
|
2008-6-2 00:24 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 28 楼』:
使用 LLM 解释/回答一下
9分19点1日2月2008年,这个好算,下面这个就不好算了:
2008年4月20日20点10分的前2个月48天29个小时78分钟
Last edited by zw19750516 on 2008-6-2 at 12:31 AM ]
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
|

批处理之家新域名:www.bathome.net |
|
2008-6-2 00:30 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 29 楼』:
使用 LLM 解释/回答一下
算了,可能真的是我太想复杂了(事实上根本不存在如20年前39个月500天6000个小时10000分钟之说),明天还要上班,先睡觉了,谢谢兄弟们了。
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.
|

批处理之家新域名:www.bathome.net |
|
2008-6-2 00:37 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 30 楼』:
使用 LLM 解释/回答一下
Originally posted by zw19750516 at 2008-6-2 00:30:
9分19点1日2月2008年,这个好算,下面这个就不好算了:
Last edited by zw19750516 on 2008-6-2 at 12:31 AM ]
你这个难道不是减去整2个月吗?
先减去分,时、天、结果为:2008年4月1日19点9分
再减去2整月、即:4减2 得到 2008年2月1日19点9分
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
|

致精致简! |
|
2008-6-2 00:43 |
|
|