Skip to content

Commit 224de46

Browse files
tristanbob4ian
andauthored
[TimeFormatter] Added an expression for HH:MM:SS.000 (displays milliseconds) (#711)
* [TimeFormatter] Added an expression for HH:MM:SS.000 (displays milliseconds) Co-authored-by: Florian Rival <[email protected]>
1 parent c6b3c35 commit 224de46

File tree

1 file changed

+72
-14
lines changed

1 file changed

+72
-14
lines changed
Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
{
22
"author": "@Bouh",
33
"category": "User interface",
4-
"description": "Expressions to transform time in seconds to format like HH:MM:SS. Ideal to display timers on screen.",
54
"extensionNamespace": "",
65
"fullName": "Time formatting",
76
"helpPath": "",
87
"iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWNsb2NrLWRpZ2l0YWwiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMiw2QTIsMiAwIDAsMCAwLDhWMTZBMiwyIDAgMCwwIDIsMThIMjJBMiwyIDAgMCwwIDI0LDE2VjhBMiwyIDAgMCwwIDIyLDZNMiw4SDIyVjE2SDJNMyw5VjEwLjVINi4yNUwzLDE1SDQuNzVMOCwxMC41VjlNOS4yNSw5VjEwLjVIMTAuNzVWOU0xMiw5VjEwLjVIMTMuNVYxNUgxNVY5TTE3LDlBMSwxIDAgMCwwIDE2LDEwVjE0QTEsMSAwIDAsMCAxNywxNUgyMEExLDEgMCAwLDAgMjEsMTRWMTBBMSwxIDAgMCwwIDIwLDlNMTcuNSwxMC41SDE5LjVWMTMuNUgxNy41TTkuMjUsMTMuNVYxNUgxMC43NVYxMy41IiAvPjwvc3ZnPg==",
98
"name": "TimeFormatter",
109
"previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/clock-digital.svg",
11-
"shortDescription": "Expressions to transform time in seconds to format like HH:MM:SS. Ideal to display timers on screen.",
12-
"version": "0.0.1",
10+
"shortDescription": "Converts seconds into standard time formats, such as HH:MM:SS. ",
11+
"version": "0.0.2",
12+
"description": [
13+
"Ideal for displaying timers on screen.",
14+
"",
15+
"Formats included:",
16+
"* HH:MM:SS",
17+
"* HH:MM:SS.000 (displays milliseconds)"
18+
],
19+
"origin": {
20+
"identifier": "TimeFormatter",
21+
"name": "gdevelop-extension-store"
22+
},
1323
"tags": [
1424
"time",
1525
"timer",
1626
"format",
1727
"hours",
1828
"minutes",
19-
"seconds"
29+
"seconds",
30+
"milliseconds"
2031
],
2132
"authorIds": [
2233
"2OwwM8ToR9dx9RJ2sAKTcrLmCB92"
@@ -28,33 +39,80 @@
2839
"fullName": "Format time in seconds to HH:MM:SS",
2940
"functionType": "StringExpression",
3041
"name": "SecondsToHHMMSS",
31-
"private": false,
3242
"sentence": "Format time _PARAM1_ to HH:MM:SS in _PARAM2_",
3343
"events": [
3444
{
35-
"disabled": false,
36-
"folded": false,
3745
"type": "BuiltinCommonInstructions::JsCode",
38-
"inlineCode": "//custom function in custom fonction ~~Woow~~\r\nvar format_time = function (time_second) {\r\n date = new Date(null);\r\n date.setSeconds(time_second);\r\n if (time_second >= 3600) {\r\n return date.toISOString().substr(11, 8); // MM:SS\r\n } else {\r\n return date.toISOString().substr(14, 5); // HH:MM:SS\r\n }\r\n}\r\n\r\neventsFunctionContext.returnValue = format_time(eventsFunctionContext.getArgument(\"TimeInSeconds\"));",
46+
"inlineCode": [
47+
"var format_time = function (time_second) {\r",
48+
" date = new Date(null);\r",
49+
" date.setSeconds(time_second);\r",
50+
" if (time_second >= 3600) {\r",
51+
" return date.toISOString().substr(11, 8); // MM:SS\r",
52+
" } else {\r",
53+
" return date.toISOString().substr(14, 5); // HH:MM:SS\r",
54+
" }\r",
55+
"}\r",
56+
"\r",
57+
"eventsFunctionContext.returnValue = format_time(eventsFunctionContext.getArgument(\"TimeInSeconds\"));"
58+
],
59+
"parameterObjects": "",
60+
"useStrict": false,
61+
"eventsSheetExpanded": false
62+
}
63+
],
64+
"expressionType": {
65+
"type": "string"
66+
},
67+
"parameters": [
68+
{
69+
"description": "Time, in seconds",
70+
"name": "TimeInSeconds",
71+
"type": "expression"
72+
}
73+
],
74+
"objectGroups": []
75+
},
76+
{
77+
"description": "Format time in seconds to HH:MM:SS.000, including milliseconds.",
78+
"fullName": "Format time in seconds to HH:MM:SS.000",
79+
"functionType": "StringExpression",
80+
"name": "SecondsToHHMMSS000",
81+
"sentence": "Format time _PARAM1_ to HH:MM:SS in _PARAM2_",
82+
"events": [
83+
{
84+
"type": "BuiltinCommonInstructions::JsCode",
85+
"inlineCode": [
86+
"var format_time = function (time_second) {\r",
87+
" date = new Date(null);\r",
88+
" date.setMilliseconds(1000*time_second);\r",
89+
" if (time_second >= 3600) {\r",
90+
" return date.toISOString().substr(11, 12); // MM:SS.000\r",
91+
" } else {\r",
92+
" return date.toISOString().substr(14, 9); // HH:MM:SS.000\r",
93+
" }\r",
94+
"}\r",
95+
"\r",
96+
"eventsFunctionContext.returnValue = format_time(eventsFunctionContext.getArgument(\"TimeInSeconds\"));"
97+
],
3998
"parameterObjects": "",
4099
"useStrict": false,
41100
"eventsSheetExpanded": false
42101
}
43102
],
103+
"expressionType": {
104+
"type": "string"
105+
},
44106
"parameters": [
45107
{
46-
"codeOnly": false,
47-
"defaultValue": "",
48108
"description": "Time, in seconds",
49-
"longDescription": "",
50109
"name": "TimeInSeconds",
51-
"optional": false,
52-
"supplementaryInformation": "",
53110
"type": "expression"
54111
}
55112
],
56113
"objectGroups": []
57114
}
58115
],
59-
"eventsBasedBehaviors": []
116+
"eventsBasedBehaviors": [],
117+
"eventsBasedObjects": []
60118
}

0 commit comments

Comments
 (0)