mIRC Home    About    Download    Register    News    Help

Print Thread
#221510 22/05/10 07:17 PM
Joined: Dec 2002
Posts: 343
D
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 343
I still would like to suggest that $duration to be modified.

Currently
$duration(seconds,N) returns week/day/hour/minute/second format
N=2 does not include seconds
N=3 returns it in hh:nn:ss format

Suggestion
N=4 returns day/hour/minute/second format
N=5 returns day/hour/minute format without seconds
N=6 returns it in dd:hh:nn:ss format, with dd referring to the number of days

Examples
$duration(9999999) = 16wks 3days 17hrs 46mins 39secs
$duration(9999999,2) = 16wks 3days 17hrs 46mins
$duration(9999999,3) = 2777:46:39
$duration(9999999,4) = 115days 17hrs 46mins 39secs
$duration(9999999,5) = 115days 17hrs 46mins
$duration(9999999,6) = 115:17:46:39

Doomstars #221559 24/05/10 03:01 PM
Joined: Apr 2010
Posts: 30
M
Ameglian cow
Offline
Ameglian cow
M
Joined: Apr 2010
Posts: 30
Uh, why so random?

My suggestion:

Allow a format parameter
$duration(seconds,format)

that works just like the one of $asctime

example:
$duration(9999999,dd:hh:nn:ss) = 115:17:46:39

imho this would be a lot better way than providing a bunch of random presets

m0viefreak #221561 24/05/10 03:48 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Agreed. Using a format parameter makes more sense. I used that method when setting up my $DateXpander() identifier that takes $duration() and expands it to output months and years accurately based on # of days per month including leap years. It works well and is easy to remember.


Invision Support
#Invision on irc.irchighway.net
Riamus2 #221564 24/05/10 04:35 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
A problem with a format parameter is that duration cannot be broken down to months/years without specifying the start date, eg 60 days may not be exactly two months if the start date is 1st of January (since 31 + 28 = 59). One approach would be to assume months are 30 days on average (and years are 365 days). If that approach were taken, I'm sure somebody would come here complaining about this smile A related problem is the absence of a 'weeks' sequence from the available formats.

In general, the format parameter is meant to represent points in time, not durations. I'm not arguing against the feature, just pointing out that there are issues (which I'm guessing are the reason $duration has not supported a format parameter so far).


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
m0viefreak #221566 24/05/10 05:04 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Why bake this into $duration when you have $asctime($duration(...), FORMAT)


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
qwerty #221573 24/05/10 05:49 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: qwerty
A problem with a format parameter is that duration cannot be broken down to months/years without specifying the start date


You don't have to include months/years in the format parameter. I just used that as an example with how mine worked when I included a format parameter.

@argv0, yes, $asctime($duration(),format) would also work. Even so, for such a commonly used identifier, I don't see why a format parameter can't be included in the identifier.


Invision Support
#Invision on irc.irchighway.net
Riamus2 #221628 26/05/10 12:19 AM
Joined: Apr 2010
Posts: 30
M
Ameglian cow
Offline
Ameglian cow
M
Joined: Apr 2010
Posts: 30
$asctime($duration(...), FORMAT)
does not work as expected:

example:
//echo -a $asctime($duration(3600),s)
i expect "3600"
i get "1" (wtf?)
//echo -a $asctime($duration(3600),n)
i expect "60"
i get "00"


the format parameter to calculate a duration has to be a lot more intelligent than the parameter of asctime.
It has to look out if a larger time interval format parameters is present and if not it has to re-calculate the value using a smaller time interval:
n:s -> 60:0
s -> 3600


I see how this is a problem and why there are presets for $duration.

I guess it's best to use your own scripts to format a duration the way you want it.

Last edited by m0viefreak; 26/05/10 12:21 AM.
m0viefreak #221630 26/05/10 12:32 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Actually $asctime($duration(N),format) is unusable, I'm not sure why I suggested it. On a related note, your examples don't work because $duration(3600) returns "1hr" which $asctime can't interpret. And unfortunately $asctime does not start at 0:00, so it's unreliable to be used in this way.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Link Copied to Clipboard