Documentation

Una is developed by Una Technologies Limited

All rights reserved

© 2022 Una Technologies Limited

Print

Converting Text to Duration

Parse … to Duration

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>dateTimeOffset</variable></variables><block type=\"DateTime_parseDuration\" disabled=\"true\" x=\"-23\" y=\"473\"><value name=\"s\"><shadow type=\"text\" disabled=\"true\"><field name=\"TEXT\"/></shadow></value></block></xml>"}
				
			

This block is used to analyze the text into Duration.

Parameters: String

Output: Duration

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\">P20Y</field></shadow></value></block></value><next><block type=\"basic_consoleLogText\"><value name=\"text\"><block type=\"DateTime_Duration_toString\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></value></block></next></block></statement></block></xml>"}
				
			

The output:

pause ... to duration - Output
Next Transforming Number to Duration