Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
njuCZ committed Feb 27, 2020
1 parent 2069753 commit c78ceab
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,19 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte
properties := parameters.ScheduleCreateOrUpdateProperties

//start time can default to now + 7 (5 could be invalid by the time the API is called)
loc, err := time.LoadLocation(timeZone)
if err != nil {
return fmt.Errorf("error parsing timezone timezone %q: %s", timeZone, err)
}
if v, ok := d.GetOk("start_time"); ok {
t, _ := time.Parse(time.RFC3339, v.(string)) //should be validated by the schema
duration := time.Duration(5) * time.Minute
if t.Sub(time.Now().In(loc)) < duration {
return fmt.Errorf("start_time is %q and should be at least %q in the future", t, duration)
}
properties.StartTime = &date.Time{Time: t}
} else {
properties.StartTime = &date.Time{Time: time.Now().Add(time.Duration(7) * time.Minute)}
properties.StartTime = &date.Time{Time: time.Now().In(loc).Add(time.Duration(7) * time.Minute)}
}

if v, ok := d.GetOk("expiry_time"); ok {
Expand Down

0 comments on commit c78ceab

Please sign in to comment.