Skip to main content
Version: v3

WorldClock

Start from API_LEVEL 3.0 . Please refer to API_LEVEL.

World Clock Sensor.

Methods

getCount

Get the number of configured world clocks

getCount(): number

getInfo

Get the configured world clock information according to the index

getInfo(index: number): WorldClockInfo

WorldClockInfo

PropertyTypeDescriptionAPI_LEVEL
citystringCity Name3.0
cityCodestringCity code, e.g. San Francisco SFO3.0
hournumberHour3.0
minutenumberMinute3.0
timeZoneHournumberTime Zone hours3.0
timeZoneMinutenumberTime zone minutes3.0

Example

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()