- if pec.Present { presence_str = "Somebody is present !" } else { presence_str = "Everybody left." }
- if pec.DoorLock { lock_str = "locked" } else { lock_str = "unlocked" }
- if pec.DoorShut { ajar_str = "shut" } else { ajar_str = "ajar" }
- msg += fmt.Sprintf("%s (Door is %s and %s and was last used by %s)", presence_str, lock_str, ajar_str, pec.Who)
+ msg += fmt.Sprintf("%s (Door is %s and %s and was last used by %s at %s)",
+ IfThenElseStr(pec.Present, "Somebody is present!" , "Everybody left."),
+ IfThenElseStr(pec.DoorLock, "locked","unlocked"),
+ IfThenElseStr(pec.DoorShut, "shut","ajar"),
+ pec.Who,
+ time.Unix(pec.Ts,0).String())