예제 #1
0
func (self *Daemon) Dispatch(event *data.Event) {
	// Dispatch to global observers
	for _, observer := range self.observers["all"] {
		observer <- event
	}

	// Dispatch to type observers
	evtStr, _ := event.Get("type").String()
	for _, observer := range self.observers[evtStr] {
		observer <- event
	}
}
예제 #2
0
func getLocalTime(event *data.Event) time.Time {
	tzstr, e1 := event.Get("data").Get("tz").String()
	now := time.Now()
	if e1 != nil {
		return now
	}
	if tzstr == "" {
		return now
	}
	tzhours := fmt.Sprintf("%sh", tzstr)
	tzdur, e2 := time.ParseDuration(tzhours)
	if e2 != nil {
		return time.Now()
	}

	then := now.Add(tzdur)

	return then
}