Skip to content

Commit

Permalink
current date
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed May 4, 2020
1 parent c582296 commit 37fd5f1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/NetCore2Blockly/TestBlocklyHtml/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
//TODO: put this in the real application
// or copy the blockly.html files and others from wwwroot
app.UseBlocklyUI();
//app.UseBlocklyLocalStorage();//this is not necessary , if you use app.UseBlocklyUI();
app.UseBlocklySqliteStorage();
app.UseBlocklyLocalStorage();//this is not necessary , if you use app.UseBlocklyUI();
//app.UseBlocklySqliteStorage();
//this is not necessary to be added
app.UseSwagger();

Expand Down
26 changes: 20 additions & 6 deletions src/NetCore2Blockly/TestBlocklyHtml/wwwroot/blockly.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<script src="blockly/BlocklyXHRWrapper.js"></script>
<script src="blockly/convertCSV.js"></script>
<script src="blockly/exportFile.js"></script>
<script src="../../blockly/DateTime/DateTime.js"></script>
<script src="../../blockly/DateTime/CurrentDateBlock.js"></script>
<script src="blockly/DateTime/DateTime.js"></script>
<script src="blockly/DateTime/CurrentDateBlock.js"></script>
<script src="/blockly/blocklyXHR.js"></script>
<script src="/blocklyStorage"></script>

Expand Down Expand Up @@ -498,8 +498,22 @@ <h1>
</category>
<category id="JavaScriptRelated" name="JSBlocks">
<!--<block type="wait_seconds"></block>-->
<block type="modifyproperty"></block>
<block type="getproperty"></block>
<category name="Objects" id="Objects">
<block type="modifyproperty"></block>
<block type="getproperty"></block>
</category>
<category name="DateTime" id="DateTime">
<block type="fromUnixTimeToDate">
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">9072000</field>
</shadow>
</value>
</block>
<block type="displayCurrentDate">
</block>
</category>

</category>
<category id="XHR" name="Request">
<block type="blockxhrresult"></block>
Expand Down Expand Up @@ -1032,8 +1046,8 @@ <h1>
interpreter.setProperty(globalObject, 'convertToDate',
interpreter.createNativeFunction(wrapper));

var wrapper = () => displayCurrentDate();
interpreter.setProperty(globalObject, 'displayCurrentDate',
var wrapper = () => displayDateCurrent();
interpreter.setProperty(globalObject, 'displayDateCurrent',
interpreter.createNativeFunction(wrapper));

var wrapper = (href, callback) => doGet(href, callback);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Blockly.Blocks['displayCurrentDate'] = {
init: function () {
//this.appendField('Date representation of');
this.appendDummyInput()
.appendField("Current Date");

this.setOutput(true, null);
this.setColour(100);
this.setTooltip('Show current date.');
Expand All @@ -11,13 +13,13 @@

Blockly.JavaScript['displayCurrentDate'] = () => {
// let data = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_ATOMIC);
let code = 'displayCurrentDate();'
let code = 'displayDateCurrent()';
//return code;
return [code, Blockly.JavaScript.ORDER_NONE];
}

//https://www.toptal.com/software/definitive-guide-to-datetime-manipulation
let displayCurrentDate = () => {
let displayDateCurrent = () => {

//undefined - get the date format form user browser.
let today = new Date().toLocaleDateString(undefined, {
Expand All @@ -29,5 +31,5 @@ let displayCurrentDate = () => {
});

console.log(today);
return today
return today;
}

0 comments on commit 37fd5f1

Please sign in to comment.