[blockly] move all date blocks to own category, modify some documentation (#1321)

Signed-off-by: Stefan Höhn <stefan@andreaundstefanhoehn.de>
pull/1335/head
stefan-hoehn 2022-03-03 23:32:20 +01:00 committed by GitHub
parent da7cfce772
commit f2f7641913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 34 deletions

View File

@ -94,7 +94,7 @@ export default function (f7) {
}
/*
* Typed (ZonedDateTime) block that can be used with the Ephemeris check block
* Typed date (ZonedDateTime) block that can be used with the Ephemeris check block
* Allows the selection of a date. The default is the current date
* Blockly part
*/
@ -105,7 +105,7 @@ export default function (f7) {
.appendField(new FieldDatePicker('', null, { f7 }, 'date'), 'day')
this.setOutput(true, 'ZonedDateTime')
this.setColour(70)
this.setTooltip('Calender entry for ephemeris check block or other openHAB Blocks that require a day input')
this.setTooltip('Calender entry for ephemeris check block or other openHAB Blocks that require a day or date input in the format yyyy-MM-dd')
this.setHelpUrl('https://www.openhab.org/docs/configuration/actions.html#ephemeris')
}
}
@ -123,16 +123,17 @@ export default function (f7) {
/*
* Typed (ZonedDateTime) block that can be used with the Ephemeris check block
* Allows input as string in the format yyyy-MM-dd
* Allows input as string in the format format yyyy-MM-dd or yyyy-MM-dd HH:mm:ss or yyyy-MM-dd HH:mm:ss +HH:mm
* Blockly part
*/
Blockly.Blocks['oh_zdt_fromText'] = {
init: function () {
this.appendValueInput('day')
.appendField('date')
this.appendValueInput('day') // cannot be renamed for backward compatibility reasons
.appendField('datetime')
.setCheck('String')
this.setOutput(true, 'ZonedDateTime')
this.setColour(70)
this.setTooltip('Calender entry as yyyy-MM-dd for ephemeris check block or other openHAB Blocks that require a day input')
this.setTooltip('Calender entry as format yyyy-MM-dd or yyyy-MM-dd HH:mm:ss or yyyy-MM-dd HH:mm:ss +HH:mm (ZonedDateTime)')
this.setHelpUrl('https://www.openhab.org/docs/configuration/actions.html#ephemeris')
}
}
@ -162,7 +163,7 @@ export default function (f7) {
this.setOutput(true, 'String')
this.setColour(160)
this.setTooltip('converts an ephemeris date into a date string')
this.setTooltip('converts an ZonedDateTime into a date string')
this.setHelpUrl('https://www.openhab.org/docs/configuration/actions.html#ephemeris')
}
}

View File

@ -32,7 +32,11 @@ export function addDateSupport () {
'getZonedDateTime',
[
'function ' + Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_ + ' (datetime) {',
` return ${zdt}.parse(datetime + ' 00:00:00 +00:00', dtf.ofPattern('yyyy-MM-dd HH:mm:ss z'))`,
' switch (datetime.length) {\n' +
` case 10: return ${zdt}.parse(datetime + ' 00:00:00 +00:00', dtf.ofPattern('yyyy-MM-dd HH:mm:ss z'));\n` +
` case 19: return ${zdt}.parse(datetime + ' +00:00', dtf.ofPattern('yyyy-MM-dd HH:mm:ss z'));\n` +
` case 26: return ${zdt}.parse(datetime, dtf.ofPattern('yyyy-MM-dd HH:mm:ss z'));\n` +
' }',
'}'
])
return { dtf, zdt, getZonedDateTime }

View File

@ -309,7 +309,13 @@
</shadow>
</value>
</block>
<block type="oh_color_to_hsb" />
<block type="oh_color_to_hsb">
<value name="hexColor">
<shadow type="colour_picker">
<field name="COLOUR">#ff0000</field>
</shadow>
</value>
</block>
</category>
<category name="openHAB" colour="0">
@ -484,7 +490,7 @@
</block>
</category>
<category name="Ephemeris">
<category name="Dates & Times">
<block type="oh_dayoffset_today" />
<block type="oh_dayoffset">
<value name="offset">
@ -508,7 +514,18 @@
<shadow type="oh_zdt" />
</value>
</block>
<sep gap="48" />
<block type="oh_zdt_plusminus">
<value name="offset">
<shadow type="math_number">
<field name="NUM">
0
</field>
</shadow>
</value>
</block>
</category>
<category name="Ephemeris">
<block type="oh_ephemeris_check">
<value name="dayInfo">
<shadow type="oh_dayoffset_today" />
@ -571,29 +588,6 @@
</category>
<category name="Persistence">
<block type="oh_zdt_plusminus">
<value name="offset">
<shadow type="math_number">
<field name="NUM">
0
</field>
</shadow>
</value>
</block>
<block type="oh_zdt" />
<block type="oh_zdt_fromText">
<value name="day">
<shadow type="text">
<field name="TEXT">{{ new Date().toISOString().split('T')[0] }}</field>
</shadow>
</value>
</block>
<block type="oh_zdt_toText">
<value name="date">
<shadow type="oh_zdt" />
</value>
</block>
<sep gap="48" />
<block type="oh_get_persistvalue">
<value name="itemName">
<shadow type="oh_item" />