Skip to main content
Version: v3

TIME

Creating Sensors

const time = hmSensor.createSensor(hmSensor.id.TIME)

TIME instance

time: object

PropertiesDescriptionType
utcTimestamp, milliseconds from January 1, 1970 to presentnumber
yearyearnumber
monthmonthnumber
daydaynumber
hourhournumber
minuteminutenumber
secondsecondnumber
weekweek 1 - 7number
lunar_yearTraditional Chinese Calendar Yearnumber
lunar_monthTraditional Chinese Calendar Monthnumber
lunar_dayTraditional Chinese Calendar Daynumber
lunar_festivalTraditional Chinese Festivalstring
lunar_solar_termTraditional Chinese Solar Termsstring
solar_festivalGregorian Holidaysstring

time.getLunarMonthCalendar

Get information about the Chinese Lunar Calendar.

const lunar_month_cal = time.getLunarMonthCalendar()

for (let i = 0; i < lunar_month_cal.day_count; i++) {
console.log('lunar_day : ' + lunar_month_cal.lunar_days_array[i])
}

time.getShowFestival

Get the holidays displayed on that day (priority: Gregorian holidays, Chinese lunar holidays, Traditional Chinese Solar Terms).

The API only works when the watch language is set to Chinese.

const current_festival = time.getShowFestival()

Code example

// Creating Sensors
const jstime = hmSensor.createSensor(hmSensor.id.TIME)

console.log(
'The time utc: ' +
jstime.utc +
' year: ' +
jstime.year +
' month: ' +
jstime.month +
' day: ' +
jstime.day +
' hour: ' +
jstime.hour +
' minute: ' +
jstime.minute +
' second: ' +
jstime.second +
'\r\n'
)