|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
我有个思路就是求余...除365 余数Y1再先对4求余(闰年)看有几个闰年给Y1要再减几个1,得到Y2
然后Y2化成月和日即可。。。
(哈哈,还是execute够偷懒)
I have an idea, which is to take the remainder... divide by 365, the remainder Y1, then first take the remainder of Y1 divided by 4 (for leap years) to see how many leap years there are, and subtract several 1s from Y1 to get Y2. Then convert Y2 into months and days... (Haha, still execute is quite lazy)
|
|
2007-5-2 17:52 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
噢。仔细看了一下。确实考虑到了闰年。。
原理研究中?
Oh. Looked carefully. Indeed considered leap years. .
Principle research in progress?
|

知,不觉多。不知,乃求知 |
|
2007-5-2 18:10 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
Originally posted by slore at 2007-5-2 04:52 AM:
我有个思路就是求余...除365 余数Y1再先对4求余(闰年)看有几个闰年给Y1要再减几个1,得到Y2
然后Y2化成月和日即可。。。
(哈哈,还是execute够偷懒)
现在不管你偷懒与否。。。
给出大家所需要的代码出来吧。。
这一点上,无论如何请不要偷懒了。
Originally posted by slore at 2007-5-2 04:52 AM:
I have an idea, which is to use the remainder... divide by 365, the remainder Y1, then first take the remainder of Y1 divided by 4 (for leap years) to see how many leap years there are, and then subtract that number of 1s from Y1 to get Y2.
Then convert Y2 into months and days...
(Haha, still execute is quite lazy)
Now regardless of whether you are lazy or not...
Please come up with the code that everyone needs.
In this regard, please don't be lazy no matter what.
|

知,不觉多。不知,乃求知 |
|
2007-5-2 18:24 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
晕死,好像叫新建 脚本文件.vbs
貌似删除了。。那重写看看好了=。=
Oh, it seems like it's called New Script File.vbs. It seems to have been deleted. Then let's rewrite it, okay?
|
|
2007-5-2 18:28 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
Originally posted by slore at 2007-5-2 05:28 AM:
晕死,好像叫新建 脚本文件.vbs
貌似删除了。。那重写看看好了=。=
呵呵,辛苦了:)
期盼ing。
Originally posted by slore at 2007-5-2 05:28 AM:
Oh my god, it seems to be called New Script File.vbs
It seems to be deleted.. Then let's rewrite it = =
Hehe, thanks for your hard work:)
Looking forward to it.
|

知,不觉多。不知,乃求知 |
|
2007-5-2 18:36 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
 『第 21 楼』:
使用 LLM 解释/回答一下
Dim ADYear
Dim ADMonth
Dim ADDay
Dim ADDDay
Dim RnMod
Dim Mon(12)
Dim strDate, strADDay
strDate = "2007-3-4"
strADDay = 800
ADYear = Year(strDate)
RnMod = ADYear Mod 4
If RnMod = 0 Then tempRNYear = 1
ADMonth = Month(strDate)
ADDay = Day(strDate)
strADDay = strADDay + Date2Day(ADYear, ADMonth, ADDay)
tempYear = strADDay \ 365
tempRNday = strADDay Mod 365
If tempYear <> 0 Then
tempRNYear = tempRNYear + (RnMod + tempYear) \ 4
tempRNday = tempRNday - tempRNYear
End If
ADYear = ADYear + tempYear
MsgBox Day2Date(ADYear, tempRNday)
Function Date2Day(ByVal y, ByVal m, ByVal d)
Mon(1) = 31: Mon(2) = 28: Mon(3) = 31: Mon(4) = 30: Mon(5) = 31: Mon(6) = 30
Mon(7) = 31: Mon(8) = 31: Mon(9) = 30: Mon(10) = 31: Mon(11) = 30: Mon(12) = 31
Date2Day = 0
If IsDate(y & "/2/29") Then Mon(2) = 29
Dim i
For i = 1 To m - 1
Date2Day = Date2Day + Mon(i)
Next
Date2Day = Date2Day + d
End Function
Function Day2Date(ByVal y, ByVal Days)
Mon(2) = 28
If IsDate(y & "/2/29") Then Mon(2) = 29
Dim i
If Days > 31 Then
For i = 1 To 11
If Days < Mon(i) Then Exit For
Days = Days - Mon(i)
Next
ADMonth = i
Else
ADMonth = 1
End If
Day2Date = y & "-" & ADMonth & "-" & Days
End Function
因为每400年有97个闰年,所以存在过8年才一个闰年的情况,所以2000年为初始年的话,你不要去计算146000后的日子,那样会差1,2天,因为我是按每4年一个闰年算的。
这里我只写了+上天数的。。。-的自己改。。。我写这个只是用代码呈现下我的思路而已。。。
Dim ADYear
Dim ADMonth
Dim ADDay
Dim ADDDay
Dim RnMod
Dim Mon(12)
Dim strDate, strADDay
strDate = "2007-3-4"
strADDay = 800
ADYear = Year(strDate)
RnMod = ADYear Mod 4
If RnMod = 0 Then tempRNYear = 1
ADMonth = Month(strDate)
ADDay = Day(strDate)
strADDay = strADDay + Date2Day(ADYear, ADMonth, ADDay)
tempYear = strADDay \ 365
tempRNday = strADDay Mod 365
If tempYear <> 0 Then
tempRNYear = tempRNYear + (RnMod + tempYear) \ 4
tempRNday = tempRNday - tempRNYear
End If
ADYear = ADYear + tempYear
MsgBox Day2Date(ADYear, tempRNday)
Function Date2Day(ByVal y, ByVal m, ByVal d)
Mon(1) = 31: Mon(2) = 28: Mon(3) = 31: Mon(4) = 30: Mon(5) = 31: Mon(6) = 30
Mon(7) = 31: Mon(8) = 31: Mon(9) = 30: Mon(10) = 31: Mon(11) = 30: Mon(12) = 31
Date2Day = 0
If IsDate(y & "/2/29") Then Mon(2) = 29
Dim i
For i = 1 To m - 1
Date2Day = Date2Day + Mon(i)
Next
Date2Day = Date2Day + d
End Function
Function Day2Date(ByVal y, ByVal Days)
Mon(2) = 28
If IsDate(y & "/2/29") Then Mon(2) = 29
Dim i
If Days > 31 Then
For i = 1 To 11
If Days < Mon(i) Then Exit For
Days = Days - Mon(i)
Next
ADMonth = i
Else
ADMonth = 1
End If
Day2Date = y & "-" & ADMonth & "-" & Days
End Function
Because there are 97 leap years every 400 years, there is a situation where there is a leap year every 8 years. So if 2000 is the initial year, don't calculate the days after 146000, because it will be off by 1 or 2 days, because I calculate based on a leap year every 4 years.
Here I only wrote the part of adding days... You can modify the part of subtracting days by yourself... I wrote this just to present my idea with code...
|
|
2007-5-2 20:41 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
8000天也是很快的。。。呵呵
在strADDay=800下面加:
execute("msgbox #" & strDate & "#+" & strADDay)验证下。。。
10000还是正确的。。2000000就乱78糟了。。。我不改了。。。思路明白就OK
8000 days is also very fast... Hehe
Add below strADDay=800:
execute("msgbox #" & strDate & "#+" & strADDay) to verify...
10000 is still correct.. 2000000 is a mess... I won't change it... As long as the idea is clear, it's OK
|
|
2007-5-2 20:45 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
刚刚测试了一下。。还算标准。。。
我写的不够用。。到时再换新的上来。。。
Just tested it.. still relatively standard...
What I wrote is not enough.. I'll replace it with a new one later...
|

知,不觉多。不知,乃求知 |
|
2007-5-2 21:27 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
|
2007-6-8 08:56 |
|
|
bjsh
银牌会员
    
积分 2000
发帖 621
注册 2007-1-1
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
Originally posted by flyinspace at 2007-5-2 05:34 PM:
算法很简单。。
也比我的用得聪明。。。但因为没有考虑闰年的存在。。
计算长一点的天数时就会出问题。。。
若加入闰年的判断。。会好很多。
没仔细看willsort的代码;
但是 瞥到了这一句;
dd+y*365+y/4-y/100+y/400
这一句 就说明了考虑到了闰年;
这种用法不是挺经典的算法么
Originally posted by flyinspace at 2007-5-2 05:34 PM:
The algorithm is very simple.
Also smarter than mine... But because it didn't consider the existence of leap years.
There will be problems when calculating longer periods of days...
Adding a leap year judgment will be much better.
Didn't look closely at willsort's code;
But caught this line;
dd+y*365+y/4-y/100+y/400
This line shows that leap years are considered;
Isn't this usage a very classic algorithm?
|
|
2007-6-8 10:44 |
|
|
okmhy
新手上路

积分 15
发帖 7
注册 2006-6-23
状态 离线
|
『第 26 楼』:
顶~!
使用 LLM 解释/回答一下
很多代码看不懂....紧急学习中..
A lot of code is not understandable.... Urgently studying...
|
|
2007-6-12 23:55 |
|
|
poopoo
新手上路

积分 2
发帖 1
注册 2008-4-17
状态 离线
|
|
2008-4-17 17:19 |
|
|
microshaoft
新手上路

积分 4
发帖 4
注册 2009-11-24
状态 离线
|
|
2009-11-28 13:55 |
|