> 

 > 

4. 以積木式編程製作網絡應用程式
日期時間
日期時間

本文件提供有關處理 DateTimeOffset 和期間的全面詳細資訊,包括轉換、格式化、計算、修改和驗證日期時間數據。

DateTimeOffset

將文本轉換為 DateTimeOffset 格式

解析…到 DateTimeOffset

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_parseDateTimeOffset\"><value name=\"s\"><shadow type=\"text\"><field name=\"TEXT\"/></shadow></value></block></xml>"}

此塊用於將文本分析到 DateTimeOffset 中。

參數: 字串
輸出: DateTimeOffset
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>mainLayout</variable><variable>mainScreen</variable><variable>dateTimeOffset</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_parseDateTimeOffset\"><value name=\"s\"><shadow type=\"text\"><field name=\"TEXT\">2020-08-16</field></shadow></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

解析到 DateTimeOffset - 輸出

生成具有不同單位的 DateTimeOffset

使用 2020 年創建 DateTimeOffset

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_createDateTimeOffset\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"0\" _input_init=\"false\"></mutation><value name=\"year\"><shadow type=\"math_number\"><field name=\"NUM\">2020</field></shadow></value></block></xml>"}

此塊用於隨時間生成新的 DateTimeOffset。

參數: 數字(預設值:2020)
輸出: DateTimeOffset
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_createDateTimeOffset\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"6\" _input_init=\"true\"></mutation><value name=\"year\"><shadow type=\"math_number\"><field name=\"NUM\">2020</field></shadow></value><value name=\"month\"><shadow type=\"math_number\"><field name=\"NUM\">5</field></shadow></value><value name=\"day\"><shadow type=\"math_number\"><field name=\"NUM\">3</field></shadow></value><value name=\"hour\"><shadow type=\"math_number\"><field name=\"NUM\">23</field></shadow></value><value name=\"minute\"><shadow type=\"math_number\"><field name=\"NUM\">22</field></shadow></value><value name=\"second\"><shadow type=\"math_number\"><field name=\"NUM\">50</field></shadow></value><value name=\"offset\"><shadow type=\"text\"><field name=\"TEXT\">+25:35</field></shadow></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

使用當前時間創建 DateTimeOffset - 輸出

使用 Unix 時間生成 DateTimeOffset

從 Unix 時間創建 DateTimeOffset,以毫秒為 0

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_fromUnixTimeMilliseconds\"><value name=\"milliseconds\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow></value></block></xml>"}

此塊用於使用 Unix 時間(以毫秒為單位)生成新的 DateTimeOffset。

參數: 數字(預設值:0)
輸出: DateTimeOffset
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_fromUnixTimeMilliseconds\"><value name=\"milliseconds\"><shadow type=\"math_number\"><field name=\"NUM\">500</field></shadow></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

從 Unix 時間建立 DateTimeOffset(以毫秒為單位) - 輸出

使用當前時間顯示 DateTimeOffset

使用當前時間創建 DateTimeOffset

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_now\"/></xml>"}

此塊用於使用當前時間生成新的 DateTimeOffset。

參數: N/A
輸出: DateTimeOffset
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

使用當前時間創建 DateTimeOffset - 輸出

將新偏移量與 DateTimeOffset 合併

將 dateTimeOffset 轉換為偏移量 +00:00

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_convertOffset\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"offset\"><shadow type=\"text\"><field name=\"TEXT\">+00:00</field></shadow></value></block></xml>"}

此塊用於將 DateTimeOffset 與新的偏移量組合在一起。

參數:

  • DateTimeOffset
  • 字串

輸出: DateTimeOffset
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"DateTime_DateTimeOffset_convertOffset\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"offset\"><shadow type=\"text\"><field name=\"TEXT\">+08:00</field></shadow></value></block></value></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

將 dateTimeOffset 轉換為偏移量 +0000 - 輸出

修改偏移量

將 dateTimeOffset 的偏移量設置為 +00:00

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_setOffset\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"offset\"><shadow type=\"text\"><field name=\"TEXT\">+00:00</field></shadow></value></block></xml>"}

此塊用於設置與原始 DateTimeOffset 的新偏移量。

參數:

  • DateTimeOffset
  • 字串

輸出: DateTimeOffset
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"DateTime_DateTimeOffset_setOffset\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"offset\"><shadow type=\"text\"><field name=\"TEXT\">+07:00</field></shadow></value></block></value></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

將 dateTimeOffset 的偏移量設置為 +0000 - 輸出

將 DateTimeOffset 的格式更改為文字格式

dateTimeOffset 轉換為格式為 yyyy-MM-dd HH:mm:ss ZZ 的字串

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_toFormat\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"format\"><shadow type=\"text\"><field name=\"TEXT\">yyyy-MM-dd HH:mm:ss ZZ</field></shadow></value></block></xml>"}

此塊用於將 DateTimeOffset 更改為特定的字串格式。

參數:

  • DateTimeOffset
  • 字串

輸出: 字串
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toFormat\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"format\"><shadow type=\"text\"><field name=\"TEXT\">yyyy-MM-dd HH:mm:ss ZZ</field></shadow></value></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

DateTimeOffset 轉換為格式為 yyyy-MM-dd HHmmss ZZ - 輸出

將 DateTimeOffset 轉換為文字格式

dateTimeOffset 轉換為字串

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></xml>"}

此塊用於將 DateTimeOffset 轉換為字串。

參數: DateTimeOffset
輸出: 字串
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

dateTimeOffset 到字串 - 輸出

將 DateTimeOffset 與 期間 相加

dateTimeOffset + 持續時間

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_arithmetic\"><field name=\"op\">PlusMinus.Plus</field><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></xml>"}

此塊用於添加日期、時間偏移量和持續時間。

參數:

  • DateTimeOffset
  • 期間

輸出: 持續時間示例
代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>mainLayout</variable><variable>mainScreen</variable><variable>duration</variable><variable>dateTimeOffset</variable><variable>currentTime</variable><variable>calculate</variable><variable>layout</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_createDateTimeOffset\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"5\" _input_init=\"true\"></mutation><value name=\"year\"><shadow type=\"math_number\"><field name=\"NUM\">2020</field></shadow></value><value name=\"month\"><shadow type=\"math_number\"><field name=\"NUM\">3</field></shadow></value><value name=\"day\"><shadow type=\"math_number\"><field name=\"NUM\">23</field></shadow></value><value name=\"hour\"><shadow type=\"math_number\"><field name=\"NUM\">5</field></shadow></value><value name=\"minute\"><shadow type=\"math_number\"><field name=\"NUM\">30</field></shadow></value><value name=\"second\"><shadow type=\"math_number\"><field name=\"NUM\">25</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">currentTime</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_createDateTimeOffset\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"5\" _input_init=\"true\"></mutation><value name=\"year\"><shadow type=\"math_number\"><field name=\"NUM\">2021</field></shadow></value><value name=\"month\"><shadow type=\"math_number\"><field name=\"NUM\">3</field></shadow></value><value name=\"day\"><shadow type=\"math_number\"><field name=\"NUM\">23</field></shadow></value><value name=\"hour\"><shadow type=\"math_number\"><field name=\"NUM\">5</field></shadow></value><value name=\"minute\"><shadow type=\"math_number\"><field name=\"NUM\">30</field></shadow></value><value name=\"second\"><shadow type=\"math_number\"><field name=\"NUM\">25</field></shadow></value></block></value><next><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_DateTimeOffset_diff\"><field name=\"maxDurationUnit\">DurationUnit.Minutes</field><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"other\"><block type=\"variables_get\"><field name=\"VAR\">currentTime</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">calculate</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_DateTimeOffset_arithmetic\"><field name=\"op\">PlusMinus.Minus</field><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\"/></shadow><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">calculate</field></block></value></block></value></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}

當它們相加時,輸出:

DateTimeOffset - 持續時間 - 輸出

當將它們相減時,輸出:

DateTimeOffset + 期間 - 輸出

計算兩個 DateTimeOffsets 之間的持續時間

獲取 dateTimeOffset 和 … 之間的持續時間最大單位年數

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_diff\"><field name=\"maxDurationUnit\">DurationUnit.Years</field><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></xml>"}

此塊用於顯示兩個 DateTimeOffset 之間的差異。

參數:

  • DateTimeOffset
  • 條件:年(預設)/月/日/小時/分鐘/秒/毫秒

輸出: 持續時間示例
代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_createDateTimeOffset\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"5\" _input_init=\"true\"></mutation><value name=\"year\"><shadow type=\"math_number\"><field name=\"NUM\">2020</field></shadow></value><value name=\"month\"><shadow type=\"math_number\"><field name=\"NUM\">3</field></shadow></value><value name=\"day\"><shadow type=\"math_number\"><field name=\"NUM\">23</field></shadow></value><value name=\"hour\"><shadow type=\"math_number\"><field name=\"NUM\">5</field></shadow></value><value name=\"minute\"><shadow type=\"math_number\"><field name=\"NUM\">30</field></shadow></value><value name=\"second\"><shadow type=\"math_number\"><field name=\"NUM\">25</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">currentTime</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><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_DateTimeOffset_diff\"><field name=\"maxDurationUnit\">DurationUnit.Years</field><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">currentTime</field></block></value><value name=\"other\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><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></value></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

獲取介於 dateTimeOffset 和最大單位年之間的持續時間 - 輸出

檢查DateTimeOffsets是否相同

dateTimeOffset = …

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_equals\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></xml>"}

此塊用於檢查兩個 DateTimeOffsets 是否相同。

參數: DateTimeOffset
輸出: 布爾值(True/False)
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_createDateTimeOffset\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"0\" _input_init=\"false\"></mutation><value name=\"year\"><shadow type=\"math_number\"><field name=\"NUM\">2020</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_DateTimeOffset_equals\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"other\"><block type=\"DateTime_parseDateTimeOffset\"><value name=\"s\"><shadow type=\"text\"><field name=\"TEXT\">2020</field></shadow></value></block></value></block></value><statement name=\"DO0\"><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">Both of them are the same.</field></shadow></value></block></value></block></statement><statement name=\"ELSE\"><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">They are different</field></shadow></value></block></value></block></statement></block></next></block></next></block></next></block></statement></block></xml>"}

如果為 true,則輸出:

dateTimeOffset = - True 輸出

當為 false 時,輸出:

dateTimeOffset = - 錯誤輸出

以毫秒為單位顯示 DateTimeOffset

dateTimeOffset 轉換為 Unix 時間(以毫秒為單位)

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_toUnixTimeMilliseconds\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></xml>"}

此塊用於在 Unix 時間中顯示 DateTimeOffset。

參數: DateTimeOffset
輸出: 數位
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">unixTime</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_DateTimeOffset_toUnixTimeMilliseconds\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"typescript_expression\"><field name=\"EXPRESSION\">unixTime.toString()</field></block></value></block></value></block></next></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

dateTimeOffset 轉換為 Unix 時間(以毫秒為單位) - 輸出

以不同的時間格式顯示 DateTimeOffset

dateTimeOffset 獲取年份

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_get\"><field name=\"unit\">DateTimeUnit.Year</field><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></xml>"}

這個塊用於以不同的格式顯示時間。

參數:

  • DateTimeOffset
  • 條件: 年(預設)/ 月 / 日 / 小時 / 分鐘 / 秒 / 毫秒 / 偏移量 / 週年 / 週數 / 週日

輸出: 數位
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">time</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_DateTimeOffset_get\"><field name=\"unit\">DateTimeUnit.Year</field><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">time</field></block></value></block></value></block></value></block></next></block></next></block></next></block></next></block></statement></block></xml>"}

當它設定為 Year 時,輸出:

dateTimeOffset get Year - 輸出

當它設定為 Month 時,輸出:

dateTimeOffset get Month - 輸出

當它設定為 Day 時,輸出:

dateTimeOffset get Day - 輸出

當它設定為 Hour 時,輸出:

dateTimeOffset 獲取 Hour- 輸出

當它設置為 Minute 時,輸出:

dateTimeOffset get Minute - 輸出

當它設定為 Second 時,輸出:

dateTimeOffset get Second - 輸出

當它設定為毫秒時,輸出:

dateTimeOffset get Millisecond - 輸出

當它設定為 Offset 時,輸出:

dateTimeOffset get Offset - 輸出

當它設置為 WeekYear 時,輸出:

dateTimeOffset get WeekYear - 輸出

當它設置為 WeekNumber 時,輸出:

dateTimeOffset get WeekNumber - 輸出

當它設定為 WeekDay 時,輸出:

dateTimeOffset get WeekDay - 輸出

檢查 DateTimeOffset 的類型是否正確

dateTimeOffset 有效

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_DateTimeOffset_isValid\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></xml>"}

此塊用於檢查 DateTimeOffset 的數據類型是否正確。

參數: DateTimeOffset
輸出: 布爾值(True/False)
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></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_DateTimeOffset_isValid\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value><statement name=\"DO0\"><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">This is valid.</field></shadow></value></block></value></block></statement><statement name=\"ELSE\"><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">This is not valid.</field></shadow></value></block></value></block></statement></block></next></block></next></block></next></block></statement></block></xml>"}

當它處於正確的資料類型時,輸出:

dateTimeOffset 有效 - True 輸出

當它的資料類型錯誤時,輸出:

dateTimeOffset 有效 - False 輸出

期間

將文本轉換為持續時間

解析…至持續時間

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_parseDuration\"><value name=\"s\"><shadow type=\"text\"><field name=\"TEXT\"/></shadow></value></block></xml>"}

此塊用於將文本分析為期間。

參數: 字串
輸出: 持續時間示例
代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><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=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><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></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

解析到 DateTimeOffset - 輸出

將數位轉換為持續時間

創建持續時間為 0 年

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_createDuration\"><field name=\"unit\">DurationUnit.Years</field><value name=\"value\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow></value></block></xml>"}

此塊用於將數位生成為期間。

參數:

  • 數字(預設值:0)
  • 條件:年(預設)/月/天/小時/分鐘/秒/毫秒

輸出: 持續時間示例
代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><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.Years</field><value name=\"value\"><shadow type=\"math_number\"><field name=\"NUM\">50</field></shadow></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><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></value></block></next></block></next></block></next></block></statement></block></xml>"}

當它設定為「年」時,輸出:

創建持續時間 0 年 - 輸出

當它設置為 Months 時,輸出:

dateTimeOffset get Month - 輸出

當它設定為 Days 時,輸出:

創建持續時間 0 天 - 輸出

當它設定為 Hours 時,輸出:

創建持續時間 0 小時 - 輸出

當它設定為分鐘時,輸出:

創建持續時間 0 分鐘 - 輸出

當它設定為 Seconds 時,輸出:

創建持續時間 0 秒 - 輸出

當它設定為毫秒時,輸出:

創建持續時間為 0 毫秒 - 輸出

將字串轉換為持續時間

字串的持續時間

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_Duration_toString\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></xml>"}

此塊用於將期間分析為文字。

參數: 期間
輸出: 字串
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><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.Years</field><value name=\"value\"><shadow type=\"math_number\"><field name=\"NUM\">50</field></shadow></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><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></value></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

字串的持續時間 - 輸出

製作相反的持續時間

否定持續時間

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_Duration_negate\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></xml>"}

此塊用於使持續時間變得相反。

參數: 期間
輸出: 持續時間示例
代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><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.Years</field><value name=\"value\"><shadow type=\"math_number\"><field name=\"NUM\">50</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">negation</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_Duration_negate\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_Duration_toString\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">negation</field></block></value></block></value></block></value></block></next></block></next></block></next></block></next></block></statement></block></xml>"}

輸出:

否定持續時間 - 輸出

添加兩個持續時間

期間 + …

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_Duration_arithmetic\"><field name=\"op\">PlusMinus.Plus</field><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></xml>"}

此塊用於將兩個持續時間相加。

參數:

  • 期間
  • 條件:+(預設)/-

輸出: 持續時間示例
代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>mainLayout</variable><variable>mainScreen</variable><variable>duration</variable><variable>dateTimeOffset</variable><variable>currentTime</variable><variable>calculate</variable><variable>layout</variable><variable>sum</variable><variable>secondDuration</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_createDateTimeOffset\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"5\" _input_init=\"true\"></mutation><value name=\"year\"><shadow type=\"math_number\"><field name=\"NUM\">2020</field></shadow></value><value name=\"month\"><shadow type=\"math_number\"><field name=\"NUM\">3</field></shadow></value><value name=\"day\"><shadow type=\"math_number\"><field name=\"NUM\">23</field></shadow></value><value name=\"hour\"><shadow type=\"math_number\"><field name=\"NUM\">5</field></shadow></value><value name=\"minute\"><shadow type=\"math_number\"><field name=\"NUM\">30</field></shadow></value><value name=\"second\"><shadow type=\"math_number\"><field name=\"NUM\">25</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">currentTime</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><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_DateTimeOffset_diff\"><field name=\"maxDurationUnit\">DurationUnit.Minutes</field><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"other\"><block type=\"variables_get\"><field name=\"VAR\">currentTime</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">secondDuration</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\">PT-769640M-40.604S</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">sum</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_Duration_arithmetic\"><field name=\"op\">PlusMinus.Plus</field><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value><value name=\"other\"><block type=\"variables_get\"><field name=\"VAR\">secondDuration</field></block></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><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></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}

將持續時間相加時,輸出:

持續時間 + - 輸出

減去持續時間時,輸出:

持續時間 - - 輸出

更改持續時間單位

持續時間將最大單位更改為年數

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_Duration_changeMaxUnit\"><field name=\"maxUnit\">DurationUnit.Years</field><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></xml>"}

此塊用於將原始持續時間單位更改為新單位。

參數:

  • 期間
  • 條件:年(預設)/月/天/小時/分鐘/秒/毫秒

輸出: 持續時間示例
代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><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=\"variables_set\"><field name=\"VAR\">unit</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_Duration_changeMaxUnit\"><field name=\"maxUnit\">DurationUnit.Years</field><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"DateTime_Duration_toString\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">unit</field></block></value></block></value></block></value></block></next></block></next></block></next></block></next></block></statement></block></xml>"}

當它設定為「年」時,輸出:

持續時間將最大單位更改為“年 - 輸出”

當它設置為 Months 時,輸出:

持續時間將最大單位更改為月數 - 輸出

當它設定為 Days 時,輸出:

持續時間將最大單位更改為天數 - 輸出

當它設定為 Hours 時,輸出:

持續時間將最大單位更改為小時 - 輸出

當它設定為分鐘時,輸出:

持續時間將最大單位更改為分鐘數 - 輸出

當它設定為 Seconds 時,輸出:

持續時間將最大單位更改為秒 - 輸出

當它設定為毫秒時,輸出:

持續時間將最大單位更改為毫秒 - 輸出

檢查兩個持續時間是否相同

持續時間 = …

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_Duration_equals\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></xml>"}

此塊用於檢查兩個持續時間是否相同。

參數: 期間
輸出: 布爾值(True/False)
示例代碼:

當它們相同時,輸出:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>mainLayout</variable><variable>mainScreen</variable><variable>duration</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><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=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">They are the same.</field></shadow></value></block></value></block></statement><statement name=\"ELSE\"><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">They are not the same.</field></shadow></value></block></value></block></statement></block></next></block></next></block></next></block></statement></block></xml>"}
持續時間 = - 真實輸出

當它們不同時,輸出:

持續時間 = - False 輸出

以不同單位顯示持續時間總數

持續時間獲取總年數

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_Duration_getTotal\"><field name=\"unit\">DurationUnit.Years</field><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></xml>"}

此塊用於以數位格式獲取持續時間。

參數:

  • 期間
  • 條件:年(預設)/月/天/小時/分鐘/秒/毫秒

輸出: 數位
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><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.Years</field><value name=\"value\"><shadow type=\"math_number\"><field name=\"NUM\">50</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">sum</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_Duration_getTotal\"><field name=\"unit\">DurationUnit.Years</field><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"Util_convertToText\"><value name=\"value\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"variables_get\"><field name=\"VAR\">sum</field></block></value></block></value></block></value></block></next></block></next></block></next></block></next></block></statement></block></xml>"}

當它設定為「年」時,輸出:

持續時間 獲取總年數 - 輸出

當它設置為 Months 時,輸出:

持續時間 獲取總月數 - 輸出

當它設定為 Days 時,輸出:

持續時間 獲取總天數 - 輸出

當它設定為 Hours 時,輸出:

持續時間 獲取總小時數 - 輸出

當它設定為分鐘時,輸出:

持續時間 獲取總分鐘數 - 輸出

當它設定為 Seconds 時,輸出:

持續時間:獲取總秒數-輸出

當它設定為毫秒時,輸出:

持續時間:獲取總毫秒數 - 輸出

以數位格式顯示持續時間,帶單位

持續時間獲取 年

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><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></xml>"}

此塊用於以數位格式獲取指定的持續時間。

參數:

  • 期間
  • 條件:年(預設)/月/天/小時/分鐘/秒/毫秒

輸出: 數位
示例代碼:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><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=\"variables_set\"><field name=\"VAR\">date</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><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><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><block type=\"Util_convertToText\"><value name=\"value\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"variables_get\"><field name=\"VAR\">date</field></block></value></block></value></block></value></block></next></block></next></block></next></block></next></block></statement></block></xml>"}

當它設定為「年」時,輸出:

持續時間 獲取 年 - 輸出

當它設置為 Months 時,輸出:

持續時間 獲取月份 - 輸出

當它設定為 Days 時,輸出:

持續時間 獲取天數 - 輸出

當它設定為 Hours 時,輸出:

持續時間 獲取小時數 - 輸出

當它設定為分鐘時,輸出:

持續時間 獲取分鐘 - 輸出

當它設定為 Seconds 時,輸出:

持續時間 獲取秒數 - 輸出

當它設定為毫秒時,輸出:

持續時間:獲取毫秒 - 輸出

檢查持續時間的數據類型是否正確

持續時間有效

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"DateTime_Duration_isValid\"><value name=\"duration\"><block type=\"variables_get\"><field name=\"VAR\">duration</field></block></value></block></xml>"}

此塊用於檢查持續時間的數據類型是否正確。

參數: 期間
輸出: 布爾值(True/False)
示例代碼:

當它處於正確的類型時,輸出:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><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=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">It is valid.</field></shadow></value></block></value></block></statement><statement name=\"ELSE\"><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">It is not valid.</field></shadow></value></block></value></block></statement></block></next></block></next></block></next></block></statement></block></xml>"}
持續時間有效 - Ture 輸出

當它處於錯誤的類型時,輸出:

持續時間有效 - False 輸出

目録