Documentation

Una is developed by Una Technologies Limited

All rights reserved

© 2022 Una Technologies Limited

Print

Showing Duration in Number Format with Unit

Duration get Years

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

This block is used to get the designated duration in a number format. 

Parameters:

      • Duration
      • Condition: Years (Default)/Months/Days/Hours/Minutes/Seconds/ Milliseconds

Output: Number
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=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"DateTime_Duration_get\"><field name=\"unit\">DurationUnit.Years</field><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></value></block></next></block></statement></block></xml>"}
				
			

The output:

Duration get Years - Output
Previous Displaying Total Number of Duration in Different Units
Next Checking Whether Duration is in Correct Data Type