-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNtp.m5b
1 lines (1 loc) · 2.32 KB
/
Ntp.m5b
1
{"category":"Ntp","color":"#80ffff","blocks":["__Ntp_untitled"],"jscode":"// Block __Ntp_untitled\nvar __Ntp_untitled_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"Ntp Request\"\n }\n ],\n \"colour\": \"#80ffff\"\n};\n\nwindow['Blockly'].Blocks['__Ntp_untitled'] = {\n init: function() {\n this.jsonInit(__Ntp_untitled_json);\n }\n};\n\nwindow['Blockly'].Python['__Ntp_untitled'] = function(block) {\n return `import urequests\n\ndef first_index(my_list, elem):\n try: index = my_list.index(elem) + 1\n except: index = 0\n return index\n\ndatetime = None\ntime = None\n\ntry:\n req = urequests.request(method='GET', url='http://ntp-a1.nict.go.jp/cgi-bin/time')\n datetime = (req.text).split(' ')\n time = datetime[3].split(':')\n rtc.setTime(int(datetime[4]), first_index(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], datetime[1]), int(datetime[2]), int(time[0]), int(time[1]), int(time[2]))\nexcept:\n pass` + \"\\n\";\n};\n\n","code":{"untitled":["window['Blockly'].Python['__Ntp_untitled'] = function(block) {\n return `import urequests\n\ndef first_index(my_list, elem):\n try: index = my_list.index(elem) + 1\n except: index = 0\n return index\n\ndatetime = None\ntime = None\n\ntry:\n req = urequests.request(method='GET', url='http://ntp-a1.nict.go.jp/cgi-bin/time')\n datetime = (req.text).split(' ')\n time = datetime[3].split(':')\n rtc.setTime(int(datetime[4]), first_index(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], datetime[1]), int(datetime[2]), int(time[0]), int(time[1]), int(time[2]))\nexcept:\n pass` + \"\\n\";\n};\n\n","import urequests\n\ndef first_index(my_list, elem):\n try: index = my_list.index(elem) + 1\n except: index = 0\n return index\n\ndatetime = None\ntime = None\n\ntry:\n req = urequests.request(method='GET', url='http://ntp-a1.nict.go.jp/cgi-bin/time')\n datetime = (req.text).split(' ')\n time = datetime[3].split(':')\n rtc.setTime(int(datetime[4]), first_index(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], datetime[1]), int(datetime[2]), int(time[0]), int(time[1]), int(time[2]))\nexcept:\n pass"]}}