From WikiChip
$duration Identifier - mIRC
< mirc‎ | identifiers
Revision as of 23:58, 18 August 2020 by Maroonbells (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The $duration identifier can take a specified number of seconds and return it in weeks/days/hours/minutes/seconds format. After a value has been returned, the new value can even be used with the identifier in order to return the number of seconds.

Synopsis[edit]

$duration(seconds,N)
$duration(timestring)

Parameters[edit]

seconds The specific number of seconds to get the formatting for
N Can be either 2, which omits seconds from the results, or 3, which returns the time in hh:nn:ss format Beginning v7.63 correctly handles negative durations.

Example[edit]

Echo the formatting for 38711810 seconds:

//echo -a $duration(38711810)

Result

64wks 1hr 16mins 50secs
//echo -a $duration(38711810,2)

Same except does not display the seconds. Result

64wks 1hr 16mins
//echo -a $duration(38711810,3)

Returns the display in HH:nn:ss format, with durations longer than 1 day returning hours > 23. Result

10753:16:50

Echo the formatting for converting 64wks 1hr 16mins 50secs back to seconds:

//echo -a $duration(64wks 1hr 16mins 50secs)

Result

38711810

The displayed timestring contains the time units touching their integers, so you will need to use $replace if you don't wish this:

//echo -a This computer restarted $regsubex(foo,$duration($uptime(system,3)),/([a-z]+)/g,$chr(32) $+ \t) ago!

Compatibility[edit]

Added: mIRC v4.7
Added on: 09 Dec 1996
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.

See Also[edit]