mIRC Home    About    Download    Register    News    Help

Print Thread
#126210 26/07/05 05:46 PM
Joined: Dec 2002
Posts: 483
Deep3D Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Dec 2002
Posts: 483
Code:
uptime {
  if ((!%best.uptime) || ($ticks > %best.uptime)) { set %best.uptime $ticks }
  if ($ticks >= %best.uptime) { say Windows $os uptime: $duration($calc($ticks / 1000),2) }
  else { say Windows $os uptime: $duration($calc($ticks / 1000),2) (Best: $duration($calc(%best.uptime / 1000),2) $+ ) }
}  


How can I get it to show e.x: 1month 1wks 2days 2hrs 42mins

Isted of: 5ws 2days 2hrs 42mins

#126211 26/07/05 05:49 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Use $replace(). smile

$replace($duration($calc(...)),wk,week) etc..

-Andy

#126212 26/07/05 06:14 PM
Joined: Dec 2002
Posts: 483
Deep3D Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Dec 2002
Posts: 483
yes, but I have to "add" month.

#126213 26/07/05 06:18 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You may know this, but just in case... unless you have your alias on a timer, your record uptime isn't going to be kept updated. You should separate out the display and put the alias on a timer.

As for displaying months/years... those vary and it's not possible to really determine the time. What's a month? 28, 29, 30, or 31 days? What's a year? 365, or 366 days? Or 365.25 (rounded)?

If you simply said 4 weeks = 1 month, then you'll be assuming every month is 28 days, which would be inaccurate.

Now, you *could* make a workaround if you really wanted to get into coding a lot of checks. For current uptime, you can check the current month and figure out the amount of time using that information. For your record, you could just store the output as you want it to appear.

Example (that will only work for this one... I'm not going to write the entire thing out right now):

Code:
set %days $calc($iif($gettok(%uptime,1,119) isnum,$gettok(%uptime,1,119),0) * 7 + $iif($gettok($gettok(%uptime,1,100),2,119) isnum,$gettok($gettok(%uptime,1,119),2,119),0))
if (%days > 27 && %days < 59)
  if ($date(mm) == 03) {
    set %months 1
    set %weeks $iif($calc((%days - 28) / 7) >= 1,$calc((%days - 28) / 7),0)
    set %finaldays $calc(%days - 28 - (%weeks * 7))
    echo -a %months %weeks %finaldays
  }


Note that I didn't bother with the hours/mins/secs, but that's the same idea. I also set it up with the assumption that %uptime includes your $duration of the uptime value in the format of 20wks 3days 1hr 4mins 20secs.

You can make a $days alias that will automcatically determine months based on what month it is and the number of days and so on. You basically have to determine the which months you are looking at and how many days in each month and go from there. It's not a simple script if you want it to work properly, but it can be done... for this. As long as you KNOW the starting or editing date, you can do this. For uptime, you do know the ending date.

And, remember, you put the record uptime in there as you want it displayed... not as a value that would need calculated, because you won't have your date anymore to calculate it properly.

As a final note, I wouldn't really be using a if %days > __ && %days < __ in a final script to handle this... I used that just to point out how it would work for a single time frame (over 1 month and under 2 months when the current date is in March. Note also that I didn't take into account leap year in this example, but it could easily be checked for.

I may consider making a full $days_to_months_and_years alias ... we'll see. But, it's not a quick and easy thing to do.


Invision Support
#Invision on irc.irchighway.net
#126214 26/07/05 06:32 PM
Joined: Dec 2002
Posts: 483
Deep3D Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Dec 2002
Posts: 483
Thanks for all of that.. smile

I diden't think of the month days..

#126215 26/07/05 06:53 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, usually people don't think about it. We have a nice long thread in the feature requests about it. smile


Invision Support
#Invision on irc.irchighway.net
#126216 26/07/05 11:34 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Check out my script that you can use for this here


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard