Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[blockly] move all date blocks to own category, modify some docu #1321

Merged
merged 1 commit into from Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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
*/
Expand All @@ -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')
}
}
Expand All @@ -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')
}
}
Expand Down Expand Up @@ -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')
}
}
Expand Down
Expand Up @@ -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 }
Expand Down
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand All @@ -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" />
Expand Down Expand Up @@ -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" />
Expand Down