mIRC Home    About    Download    Register    News    Help

Print Thread
#164226 09/11/06 07:41 AM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
I'm looking for a alias that acts just like $duration(), including same parameters, etc. Except, it also supports months and years.

#164227 09/11/06 01:59 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
#164228 09/11/06 02:47 PM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
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.

#164229 09/11/06 03:40 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
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.


$maybe
#164230 09/11/06 04:47 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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)


Invision Support
#Invision on irc.irchighway.net
#164231 10/11/06 02:54 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
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.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#164232 10/11/06 04:51 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
#164233 10/11/06 05:17 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
$datediff is quite simular but it wont freeze and works from the year 100 to the year 9999.


$maybe

Link Copied to Clipboard