mIRC Homepage
Posted By: bwuser duration - 09/11/06 07:41 AM
I'm looking for a alias that acts just like $duration(), including same parameters, etc. Except, it also supports months and years.
Posted By: Riamus2 Re: duration - 09/11/06 01:59 PM
Look at my $DateXpander identifier on http://www.KakkoiiTranslations.net/mircscripts/ .

It handles months and years correctly, including leap years. I'd suggest reading all information so you understand how to best use it. If you have questions, feel free to ask.
Posted By: bwuser Re: duration - 09/11/06 02:47 PM
I couldn't get it to work.

What I'm really looking for, is count down identifer, so i could enter say October 5 2007, and it'd tell me years, months, weeks, days until that date .. time is optional.
Posted By: Mpdreamz Re: duration - 09/11/06 03:40 PM
check out my $datediff identifier
http://www.mirc.net/projects.php?go=1161705144

$datediff(10/05/2007,a) will return the
years quarters months weeks days hours minutes seconds from the current dat untill that date. It's output is fully custumisable so you could specify
$datediff(10/05/2007,ymd)
to only return the years and months you can also specify your own startdate and/or suply times with the dates as well. You can read all about it at top of the file.
Posted By: Riamus2 Re: duration - 09/11/06 04:47 PM
Here is how to do what you wanted. Note that this was really an extension of $duration and wasn't originally intended for a countdown. However, it works fine as one... it just isn't as simple to use for that as it is for normal $duration stuff.

//echo -a $DateXpander($calc($ctime(Dec 25 2016 00:00:00) - $ctime),12/25/2016)

That will tell you the time until Christmas, ten years from now. Note that you do not need to include the time... I did that as an example in case you want to include it. Basically, it's the seconds between the future date/time and now, followed by the startdate (the future date is the startdate). The reason for including a future date is because this script is designed to calculate time from present back to the past, rather than present into the future, so it needs to know when to start counting back from. Obviously, that's rather cumbersome to remember, but as I said, that wasn't the intention for the script.

Normally, this script would be used like $duration...

//echo -a $duration(3454743234)
vs.
//echo -a $DateXpander(3454743234)

or, to specify only certain parts of the output (only months and days):

//echo -a $DateXpander(3454743234,md)
Posted By: Lpfix5 Re: duration - 10/11/06 02:54 PM
Well in theory you can also call $asctime to pop the year months etc... for you

$asctime(983489392,yyyy mm dd nn ss)

something of this similar but date expander perhaps works a lil better since if asctime does not have a valid year/date/month etc... it will display the largest value of the call fo example if the date was not valid in the time then the largest date would be 31 since a full calender includes 31 days.
Posted By: Riamus2 Re: duration - 10/11/06 04:51 PM
That just gives you the date/time, not a duration.

$asctime(983489392,yyyy mm dd nn ss)
2001 03 01 29 52

$datexpander(983489392)
31 years, 1 month, 4 weeks, 23 hours, 29 minutes, and 52 seconds

If you subtracted years from 1970, you'd be right for years, but months are still wrong.

Even setting $datexpander for the same parts as you used:

$datexpander(983489392,ymdns)
31 years, 1 month, 28 days, 1,409 minutes, and 52 seconds

Note that there are that many minutes, because you're not displaying the hours and it's not a full day's worth of minutes.

Also, $datexpander lets you handle larger durations than $asctime will. A word of warning... once you're past about 200 years, $datexpander will take a long time to calculate the result and will freeze you while doing so. If enough wanted it to work with hundreds/thousands of years, then I might consider optimizing the year calculations to make that faster.

One final note: The output of $datexpander will change based on WHEN you use it due to the number of days in the month.
Posted By: Mpdreamz Re: duration - 10/11/06 05:17 PM
$datediff is quite simular but it wont freeze and works from the year 100 to the year 9999.
© mIRC Discussion Forums