From a56d8058286f2eec956f839a715397f6f286ee0f Mon Sep 17 00:00:00 2001 From: fredqian Date: Sat, 22 Feb 2025 15:27:38 +0800 Subject: [PATCH] Update tuple.js --- boards/default_src/python/blocks/tuple.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/boards/default_src/python/blocks/tuple.js b/boards/default_src/python/blocks/tuple.js index b21b0639..35dd7ce3 100644 --- a/boards/default_src/python/blocks/tuple.js +++ b/boards/default_src/python/blocks/tuple.js @@ -720,13 +720,24 @@ export const tuple_totuple = { this.setTooltip(Blockly.Msg.MIXLY_PYTHON_TOOLTIP_TOTUPLE); } }; - +function getCurrentTimeTuple() { + var now = new Date(); + var year = now.getFullYear(); + var month = now.getMonth() + 1; // 月份从 0 开始,所以要加 1 + var day = now.getDate(); + var hour = now.getHours(); + var minute = now.getMinutes(); + var second = now.getSeconds(); + + // 返回元组格式的时间字符串 + return year + "," + month + "," + day + "," + hour + "," + minute + "," + second ; +} export const tuple_input = { init: function () { this.setColour(TUPLE_HUE); this.appendDummyInput("") .appendField('(') - .appendField(new Blockly.FieldTextInput('2020,1,2,3,4,5'),"CONTENT") + .appendField(new Blockly.FieldTextInput(getCurrentTimeTuple()),"CONTENT") .appendField(')'); this.setOutput(true); }