Skip to main content
版本:v3

WorldClock

API_LEVEL 3.0 开始支持,API 兼容性请参考 API_LEVEL

世界时钟传感器。

方法

getCount

获取配置的世界时钟数量

getCount(): number

getInfo

根据索引获取配置的世界时钟信息

getInfo(index: number): WorldClockInfo

WorldClockInfo

属性类型说明API_LEVEL
citystring城市名3.0
cityCodestring城市代号,如旧金山 SFO3.0
hournumber小时3.0
minutenumber分钟3.0
timeZoneHournumber时区小时3.0
timeZoneMinutenumber时区分钟3.0

代码示例

import { WorldClock } from '@zos/sensor'

const worldClock = new WorldClock()
const worldClockCount = worldClock.getCount()

for (let i = 0; i < worldClockCount; i++) {
const worldClockInfo = worldClock.getInfo(i)
console.log(worldClockInfo.city)
console.log(worldClockInfo.cityCode)
console.log(worldClockInfo.hour)
console.log(worldClockInfo.minute)
console.log(worldClockInfo.timeZoneHour)
console.log(worldClockInfo.timeZoneMinute)
}

// When not needed for use
worldClock.destroy()