python online 加块
时间戳转日期 enumerate函数
This commit is contained in:
@@ -1032,4 +1032,16 @@ export const get_unique_identifier = {
|
||||
};
|
||||
|
||||
// export const base_type = controls_type;
|
||||
// export const controls_TypeLists = controls_typeLists;
|
||||
// export const controls_TypeLists = controls_typeLists;
|
||||
|
||||
export const datetime_fromtimestamp = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_RTC_TIMESTAMP);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_TIMESTAMP_TO_DATA);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
@@ -794,3 +794,33 @@ export const lists_insert_value2 = lists_insert_value
|
||||
export const lists_remove_at2 = lists_remove_at
|
||||
export const list_tolist2 = list_tolist;
|
||||
|
||||
|
||||
export const ENUMERATE ={
|
||||
init: function () {
|
||||
this.setColour(LISTS_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.blockpy_USE_LIST);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_TO_INDEX_SEQUENCE);
|
||||
// this.appendValueInput('VAR_N')
|
||||
// .appendField(Blockly.Msg.MIXLY_INDEX+Blockly.Msg.MIXLY_STARTSWITH);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, Number);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOTO_INDEX_SEQUENC_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const enumerate = {
|
||||
init: function () {
|
||||
this.setColour(LISTS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.blockpy_USE_LIST);
|
||||
this.appendValueInput('LIST');
|
||||
this.appendValueInput('VALUE')
|
||||
.appendField(Blockly.Msg.MIXLY_TO_INDEX_SEQUENCE)
|
||||
.appendField(Blockly.Msg.MIXLY_INDEX+Blockly.Msg.MIXLY_STARTSWITH);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOTO_INDEX_SEQUENC_TOOLTIP);
|
||||
}
|
||||
};
|
||||
@@ -278,4 +278,11 @@ export const get_unique_identifier = function (_, generator) {
|
||||
}
|
||||
|
||||
// ok
|
||||
export const controls_repeat = controls_repeat_ext;
|
||||
export const controls_repeat = controls_repeat_ext;
|
||||
|
||||
export const datetime_fromtimestamp = function(_,generator){
|
||||
generator.definitions_['import_datatime'] = 'import datatime';
|
||||
var ts = generator.valueToCode(this, 'VAR', generator.ORDER_ATOMIC);
|
||||
var code = 'datatime.datatime.fromtimestamp(' + ts + ')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
@@ -253,4 +253,11 @@ export const list_tolist = function (_, generator) {
|
||||
export const list_tolist2 = function (_, generator) {
|
||||
var str = generator.valueToCode(this, 'VAR', generator.ORDER_ATOMIC) || '0'
|
||||
return [str + '.tolist()', generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const enumerate = function (_, generator) {
|
||||
var varName = generator.valueToCode(this, 'LIST', generator.ORDER_ADDITIVE) || 'mylist';
|
||||
var argument = generator.valueToCode(this, 'VALUE', generator.ORDER_ASSIGNMENT) || '0';
|
||||
var code = 'enumerate(' +varName+',start='+ argument + ')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
@@ -213,6 +213,13 @@
|
||||
</statement>
|
||||
</block>
|
||||
<block type="controls_millis"></block>
|
||||
<block type="datetime_fromtimestamp">
|
||||
<value name="VAR">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">18029</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
<block type="time_localtime"></block>
|
||||
<block type="garbage_collection"></block>
|
||||
<block type="get_mem_alloc"></block>
|
||||
@@ -894,6 +901,18 @@
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
<block type="enumerate">
|
||||
<value name="LIST">
|
||||
<shadow type="variables_get">
|
||||
<field name="VAR">mylist</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
</category>
|
||||
<category id="catTuple" colour="195">
|
||||
<block type="tuple_create_with"></block>
|
||||
|
||||
Reference in New Issue
Block a user