A Blockly advanced date picker field that uses the Google Closure date picker.
Custom date formats using token
option (e.g. yyyy-LL-dd
)
npm install --save blockly-field-date
yarn add blockly-field-date
yarn build
import * as Blockly from 'blockly';
import FieldDate from 'blockly-field-date';
Blockly.Blocks['test_field_date'] = {
init: function () {
this.appendDummyInput()
.appendField('date: ')
.appendField(new FieldDate('2022-01-11'), 'FIELDNAME');
}
};
import * as Blockly from 'blockly';
import 'blockly-field-date';
Blockly.defineBlocksWithJsonArray([
{
type: 'test_field_date',
message0: 'date: %1',
args0: [
{
type: 'field_date',
name: 'FIELDNAME',
date: '2022-01-11
}
]
}]);
Blockly.Blocks['test_field_date'] = {
init: function () {
this.appendDummyInput()
.appendField('date: ')
.appendField(new FieldDate('1/11/2022', null, true, 'L/d/yyyy'), 'FIELDNAME');
}
};
Blockly.defineBlocksWithJsonArray([
{
type: 'test_field_date',
message0: 'date: %1',
args0: [
{
type: 'field_date',
name: 'FIELDNAME',
date: '1/11/2022',
token: 'L/d/yyyy',
textEdit: true
}
]
}]);
You need to build the package first.
<script src="./dist/date_compressed.js"></script>
Apache 2.0