From WikiChip
Editing mirc/identifiers/$duration

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
{{mirc title|$duration Identifier}}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.
+
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.
  
 
Accept negative value
 
Accept negative value
Line 5: Line 5:
 
== Synopsis ==
 
== Synopsis ==
 
<pre>$duration(seconds,N)</pre>
 
<pre>$duration(seconds,N)</pre>
<pre>$duration(timestring)</pre>
+
 
 
== Parameters ==
 
== Parameters ==
 
{{ArgsList
 
{{ArgsList
Line 11: Line 11:
 
| N | Can be either '''2''', which omits seconds from the results, or '''3''', which returns the time in hh:nn:ss format
 
| 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 ==
 
== Example ==
 
Echo the formatting for '''38711810 seconds''':
 
Echo the formatting for '''38711810 seconds''':
Line 18: Line 18:
 
'''Result'''
 
'''Result'''
 
<pre>64wks 1hr 16mins 50secs</pre>
 
<pre>64wks 1hr 16mins 50secs</pre>
 
<source lang="mIRC">//echo -a $duration(38711810,2)</source>
 
Same except does not display the seconds.
 
'''Result'''
 
<pre>64wks 1hr 16mins</pre>
 
<source lang="mIRC">//echo -a $duration(38711810,3)</source>
 
Returns the display in HH:nn:ss format, with durations longer than 1 day returning hours > 23.
 
'''Result'''
 
<pre>10753:16:50</pre>
 
  
 
Echo the formatting for converting '''64wks 1hr 16mins 50secs''' back to seconds:
 
Echo the formatting for converting '''64wks 1hr 16mins 50secs''' back to seconds:
 
<source lang="mIRC">//echo -a $duration(64wks 1hr 16mins 50secs)</source>
 
<source lang="mIRC">//echo -a $duration(64wks 1hr 16mins 50secs)</source>
 +
 
'''Result'''
 
'''Result'''
 
<pre>38711810</pre>
 
<pre>38711810</pre>
  
The displayed timestring contains the time units touching their integers, so you will need to use $replace if you don't wish this:
+
== Compatibility ==
<source lang="mIRC">//echo -a This computer restarted $regsubex(foo,$duration($uptime(system,3)),/([a-z]+)/g,$chr(32) $+ \t) ago!</source>
+
Added: mIRC v4.7
  
== Compatibility ==
 
{{mIRC compatibility|4.7}}
 
 
== See Also ==
 
== See Also ==
 
* {{mIRC|$asctime}}
 
* {{mIRC|$asctime}}
 
* {{mIRC|$time}}
 
* {{mIRC|$time}}
 +
{{mIRC identifier list}}
 +
 +
[[Category:MIRC identifiers]]

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)