User Manual
Print

Checking Whether Two Durations are the Same

Duration = ...

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

This block is used to check the two durations are the same or not. 

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_createDuration\"><field name=\"unit\">DurationUnit.Months</field><value name=\"value\"><shadow type=\"math_number\"><field name=\"NUM\">50</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_equals\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value><value name=\"other\"><block type=\"DateTime_parseDuration\"><value name=\"s\"><shadow type=\"text\"><field name=\"TEXT\">P50M</field></shadow></value></block></value></block></value><statement name=\"DO0\"><block type=\"basic_consoleLogText\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">They are the same.</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"basic_consoleLogText\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">They are not the same.</field></shadow></value></block></statement></block></next></block></statement></block></xml>"}
				
			

The output:

duration = ... - Output