< >
Home » Farmbot开发入门教程 » farmbot开发入门教程-lua 时间

farmbot开发入门教程-lua 时间

说明:

  • 介绍FarmBot OS 中的时间 Lua 函数列表

等待(毫秒,参数?)

  • 暂停执行一定毫秒数。如果该值大于 1000 毫秒,则会创建一个作业来跟踪作业弹出窗口中的等待进度。您可以选择传入作业名称和状态参数来自定义作业向最终用户的显示。
-- Wait for 500 milliseconds
wait(500)

-- Wait for 5 seconds (will create a job)
wait(5000)

-- Wait for 10 seconds with a custom job name and status
wait(10000, {job = "Passing the time", status = "Watching paint dry"})

世界标准时间()

  • 返回当前 UTC 日期和时间,或其部分
-- Print the current UTC date and time in ISO 8601 format.
toast(utc())

-- Print the current UTC year. For example, `2024`.
toast(utc("year"))

-- Print the current UTC month, where January is `1` and December is `12`.
toast(utc("month"))

-- Print the current UTC day of the month. For example, `31`.
toast(utc("day"))

-- Print the current UTC hour. For example, 1:30:05 PM would return `13`.
toast(utc("hour"))

-- Print the current UTC minute. For example, 1:30:05 PM would return `30`.
toast(utc("minute"))

-- Print the current UTC second. For example, 1:30:05 PM would return `5`.
toast(utc("second"))

当地时间()

  • 根据您的 FarmBot 返回当前本地日期和时间或其部分timezone。toast(get_device("timezone"))您可以通过或在FarmBot 设置中 查看 FarmBot 的时区。
-- Print the current local date and time in ISO 8601 format.
toast(local_time())

-- Print the current local year. For example, `2024`.
toast(local_time("year"))

-- Print the current local month, where January is `1` and December is `12`.
toast(local_time("month"))

-- Print the current local day of the month. For example, `31`.
toast(local_time("day"))

-- Print the current local hour. For example, 1:30:05 PM would return `13`.
toast(local_time("hour"))

-- Print the current local minute. For example, 1:30:05 PM would return `30`.
toast(local_time("minute"))

-- Print the current local second. For example, 1:30:05 PM would return `5`.
toast(local_time("second"))

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: none