Time Converting Extension! #1368
HirujaEdurapola
started this conversation in
Show and tell
Replies: 2 comments 3 replies
-
Where's the extension? |
Beta Was this translation helpful? Give feedback.
3 replies
-
(function () {
var Extension = function () {};
Extension.prototype.getInfo = function () {
return {
id: "secondsConverterSJ",
name: "SJ Seconds Converter",
blocks: [
{
opcode: "convertSeconds",
blockType: Scratch.BlockType.REPORTER,
text: "convert [SECONDS] to hours, minutes, and seconds",
arguments: {
SECONDS: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: 3663,
},
},
},
],
};
};
Extension.prototype.convertSeconds = function (args) {
var totalSeconds = Math.floor(args.SECONDS);
var hours = Math.floor(totalSeconds / 3600);
var minutes = Math.floor((totalSeconds % 3600) / 60);
var seconds = totalSeconds % 60;
var timeString = "";
if (hours > 0) {
timeString += (hours < 10 ? "0" : "") + hours + ":";
}
timeString += (minutes < 10 ? "0" : "") + minutes + ":";
timeString += (seconds < 10 ? "0" : "") + seconds;
return timeString;
};
Scratch.extensions.register(new Extension());
})(); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've created a extension to convert seconds into Hours Minutes And Seconds. I always needed an extension to convert seconds into minutes and I think this will be very useful. I'm sharing it here cuz I have trouble uploading this extension in the gallery.
Beta Was this translation helpful? Give feedback.
All reactions