User Manual
Print

Checking Whether Duration is in Correct Data Type

Duration is valid

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>duration</variable></variables><block type=\"DateTime_Duration_isValid\" disabled=\"true\" x=\"-23\" y=\"608\"><value name=\"duration\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">duration</field></block></value></block></xml>"}
				
			

This block is used to check whether the duration is in the correct data type. 

Parameters: Duration
Output: Boolean (True/False)
Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>duration</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">duration</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_parseDuration\"><value name=\"s\"><shadow type=\"text\"><field name=\"TEXT\">P4Y3M15DT23H20M30S</field></shadow></value></block></value><next><block type=\"controls_if\"><mutation else=\"1\"/><value name=\"IF0\"><shadow type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></shadow><block type=\"DateTime_Duration_isValid\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></value><statement name=\"DO0\"><block type=\"basic_consoleLogText\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">This is valid.</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"basic_consoleLogText\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">This is not valid.</field></shadow></value></block></statement></block></next></block></statement></block></xml>"}
				
			

The output:

Duration is valid - Output