BIS fnc timeToString: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (1 revision)
m (Text replacement - "<code> *([^<|{]*) *<\/code>" to "<sqf>$1</sqf>")
 
(42 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 0.50


| arma2 |= Game name
|arg= local|eff= local|gr1= Strings


|1.00|= Game version
|descr= This function returns a 24-hour time as a string (or array) from a decimal.
____________________________________________________________________________________________


| <pre>
|s1= [time, format] call [[BIS_fnc_timeToString]]


//------------------
|p1= time: [[Number]] - time to convert (format [[dayTime]])
// Authors: Peter Morrison (snYpir) & Philipp Pilhofer (raedor)
// Purpose: This function returns a 24-hour time as a string from a decimal
// Arguments: [daytime]
// Return: boolean


/*
|p2= format: [[String]] - (Optional, default "HH:MM:SS") one of the following:
This is meant to be used with the 'daytime' command, for
* "HH"          - Hour
example if 'daytime' was 7.36, '[daytime] call TimeToString'
* "HH:MM"      - Hour:Minute
would return 07:21:36
* "HH:MM:SS"    - Hour:Minute:Seconds
* "HH:MM:SS:MM" - Hour:Minute:Seconds:Milliseconds
* "ARRAY"      - [Hour, Minute, Seconds, Milliseconds]


No rounding of the time is done - ie time is returned as per
|x1=<sqf>private _time = 7.36;
a clock
[_time] call BIS_fnc_timeToString; // 07:21:36</sqf>


The second array element passed in is the return time format.
|x2=<sqf>private _time = 7.36;
It can be:
[_time, "HH:MM"] call BIS_fnc_timeToString; // 07:21</sqf>


"HH"          - Hour
|r1= [[String]] or [[Array]]
"HH:MM"      - Hour:Minute
"HH:MM:SS"    - Hour:Minute:Seconds
"HH:MM:SS:MM" - Hour:Minute:Seconds:Milliseconds
"ARRAY"      - [Hour,Minute,Seconds,Milliseconds]
 
If the second parameter is not passed in, it defaults to
"HH:MM:SS"
*/
 
//
// Revision History:
// 09/01/08 0.1 - First cut VBS2
//------------------
 
 
</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
____________________________________________________________________________________________
 
| <!-- [] call [[BIS_fnc_timeToString]]; --> |= Syntax
 
|p1= |= Parameter 1
 
| |= Return value
____________________________________________________________________________________________
 
|x1= <code></code> |=
____________________________________________________________________________________________
 
| |= See also


|seealso= [[time]] [[dayTime]] [[BIS_fnc_secondsToString]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Strings|{{uc:timeToString}}]]
[[Category:Functions|{{uc:timeToString}}]]
[[Category:{{Name|arma2}}: Functions|{{uc:timeToString}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:timeToString}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:timeToString}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:timeToString}}]]

Latest revision as of 23:45, 12 July 2022

Hover & click on the images for description

Description

Description:
This function returns a 24-hour time as a string (or array) from a decimal.
Execution:
call
Groups:
Strings

Syntax

Syntax:
[time, format] call BIS_fnc_timeToString
Parameters:
time: Number - time to convert (format dayTime)
format: String - (Optional, default "HH:MM:SS") one of the following:
  • "HH" - Hour
  • "HH:MM" - Hour:Minute
  • "HH:MM:SS" - Hour:Minute:Seconds
  • "HH:MM:SS:MM" - Hour:Minute:Seconds:Milliseconds
  • "ARRAY" - [Hour, Minute, Seconds, Milliseconds]
Return Value:
String or Array

Examples

Example 1:
private _time = 7.36; [_time] call BIS_fnc_timeToString; // 07:21:36
Example 2:
private _time = 7.36; [_time, "HH:MM"] call BIS_fnc_timeToString; // 07:21

Additional Information

See also:
time dayTime BIS_fnc_secondsToString

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note