mIRC Homepage
What is going on with time in mIRC? - 05/02/08 01:35 AM
I don't know, maybe my calculations are wrong, but mIRC says, that this year, we have 52wks and 1day:
Code:
`\$duration(\$calc(\$ctime(31/12/2008) - \$ctime(01/01/2008))) = 52wks 1day`

BUT THIS IS INCORRECT! This all messes my trivbot, that uses mirc time to get number of week... This is leap year!
Does mIRC have forgotten about it? or maybe Khaled'n'friends? :P
Re: What is going on with time in mIRC? - 05/02/08 01:46 AM
mirc does recognize it's a leap year, you can verify that with
//echo -ag \$duration(\$calc(\$ctime(31/12/2007) - \$ctime(01/01/2007)))

You just have the wrong formula; essentially you're leaving the last day of December out of your calculations. Try this:

\$duration(\$calc(\$ctime(01/01/2009) - \$ctime(01/01/2008)))
Re: What is going on with time in mIRC? - 05/02/08 01:55 AM
Then, maybe you can suggest me an algorythm to calculate weeknumber? Mine is not working at leap year... OR, it shows American standart... but I need europe standart...
Re: What is going on with time in mIRC? - 05/02/08 02:18 AM
I'm not sure what you mean. Doesn't
\$duration(\$calc(\$ctime(01/01/2009) - \$ctime(01/01/2008)))
do what you want?
Re: What is going on with time in mIRC? - 05/02/08 02:54 AM
No...
Re: What is going on with time in mIRC? - 05/02/08 03:15 AM
If that's what you want, it's surely not what you're doing in your above code... the code above has 2 date inputs, the page only takes 1.. that's clear proof that you're performing the wrong calculation right there.

"Week number" is not the same thing as "number of weeks in a year". Europe and USA do indeed have different numbering system for the week number of a year, but that code above is not how you calculate it. If you want to know how, look no further than the JS source of the URL you posted-- you can port that implementation to mIRC.

I don't see how this is a bug-- the code you gave works fine..

Re: What is going on with time in mIRC? - 05/02/08 12:10 PM
Sorry, I did not gave you any code that counts weeks for given date
Here is my code shorthand:
Code:
`alias KN { return \$ceil(\$calc(\$calc(\$gettok(\$duration(\$calc(\$ctime(\$1 \$+ / \$+ \$2 \$+ / \$+ \$3) - \$ctime(01/01/ \$+ \$3)),3),1,58)+24) /168)) }`

And for you, to understand it:
extended version:
Code:
```alias KN {
var %now = \$ctime(\$1 \$+ / \$+ \$2 \$+ / \$+ \$3)
var %1jan = \$ctime(01/01/ \$+ \$3)
var %period = \$calc(%now - %1jan)
var %periodinhours = \$gettok(\$duration(%period,3),1,58)
var %periodplusday = %periodinhours + 24
var %countweeksinperiod = %periodplusday / 168
return \$ceil(%countweeksinperiod)
}```

Use of code: \$KN(dd,mm,yyyy)

I noticed, this, my called - bug, when tryed to fix this code with addon, that counts days in year, to make script udnerstand, if this is leap year, or not, and depending on that, correct calculation by exact days... And when I counted days, I god realy confused...
Code:
`\$calc(\$gettok(\$duration(\$calc(\$ctime(31/12/2008) - \$ctime(01/01/2008)),3),1,58)/24)`

This code tells, that we have only 365 days this year, BUT, we have 356!
Now, your suggestion made little gray mass in my mind to start moving
Code:
`\$calc(\$gettok(\$duration(\$calc(\$ctime(01/01/2009) - \$ctime(01/01/2008)),3),1,58)/24)`

Now, I will try use this code, to make correction in weeknumber code... Want to help me?

PS: You can move this post to topick, you think is best place for it...
Re: What is going on with time in mIRC? - 13/05/08 01:09 PM
Fully working week number counter scriptlet:
Input: \$weeknum(dd,mm,yyyy)
Output: <weeknumber>
Code:
Code:
`alias weeknum { return \$ceil(\$calc(\$calc(\$gettok(\$duration(\$calc(\$ctime(\$1 \$+ / \$+ \$2 \$+ / \$+ \$3) - \$ctime(01/01/ \$+ \$3)),3),1,58)+((\$calc(\$gettok(\$duration(\$calc(\$ctime(31/12/ \$+ \$3) - \$ctime(01/01/ \$+ \$3)),3),1,58)/24) - 363)*24)) /168)) }`