Repository navigation
DurationParse
imshooter edited this page Nov 26, 2026
·
1 revision
Read a duration such as 1h 30m or 2d12h.
native bool:DurationParse(const string[], &Milliseconds:output);| Parameter | Description |
|---|---|
const string[] |
The text. |
&Milliseconds:output |
The duration read. |
-
truewhen it was read. -
falsewhen the text is not a duration or is longer than 24 days.outputis left as it was.
Numbers are each followed by a unit: ms, s, m, h, d, w, or y for a year of 365 days. Units take any case, and spaces may stand anywhere between them. A longer duration fits DurationParseSeconds.
stock MutePlayer(playerid, const text[]) {
new
Milliseconds:duration
;
if (!DurationParse(text, duration)) {
return SendClientMessage(playerid, -1, "Write the time as 10m or 1h 30m.");
}
SetTimerEx("OnMuteEnd", _:duration, false, "i", playerid);
return 1;
}- DurationParseSeconds: Read a duration to the second.
- DurationFormat: Write a duration as text.
Chrono 0.2.0 · Repository · Releases · MIT License
Guides
Reference
Functions