func (c *CronScheduleResponse) LastTime() time.Time {
	return c.lastTime
}
LastTime returns the last response time
package schedule
import (
	"errors"
	"time"
	"github.com/robfig/cron"
)
var ErrMissingCronEntry = errors.New("Cron entry is missing")
type CronSchedule struct {
	entry    string
	enabled  bool
	state    ScheduleState
	schedule *cron.Cron
}
func NewCronSchedule(entry string) *CronSchedule {
	schedule := cron.New()
	return &CronSchedule{
		entry:    entry,
		schedule: schedule,
		enabled:  false,
	}
}
func (c *CronSchedule) Entry() string {
	return c.entry
}
func (c *CronSchedule) GetState() ScheduleState {
	return c.state
}
func (c *CronSchedule) Validate() error {
	if c.entry == "" {
		return ErrMissingCronEntry
	}
	_, err := cron.Parse(c.entry)
	if err != nil {
		return err
	}
	return nil
}
func (c *CronSchedule) Wait(last time.Time) Response {
	var err error
	now := time.Now()
	if (last == time.Time{}) {
		last = now
	}
	if !c.enabled {
		err = c.schedule.AddFunc(c.entry, func() {})
		if err != nil {
			c.state = Error
		} else {
			c.enabled = true
		}
	}
	var misses uint
	if c.enabled {
		s := c.schedule.Entries()[0].Schedule
		for next := last; next.Before(now); {
			next = s.Next(next)
			if next.After(now) {
				break
			}
			misses++
		}
		waitTime := s.Next(now)
		time.Sleep(waitTime.Sub(now))
	}
	return &CronScheduleResponse{
		state:    c.GetState(),
		err:      err,
		missed:   misses,
		lastTime: time.Now(),
	}
}
type CronScheduleResponse struct {
	state    ScheduleState
	err      error
	missed   uint
	lastTime time.Time
}
func (c *CronScheduleResponse) State() ScheduleState {
	return c.state
}
func (c *CronScheduleResponse) Error() error {
	return c.err
}
func (c *CronScheduleResponse) Missed() uint {
	return c.missed
}