diff --git a/crmMeeting.go b/crmMeeting.go index 39f7149..d8177cc 100644 --- a/crmMeeting.go +++ b/crmMeeting.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "fmt" "strings" "time" ) @@ -119,5 +120,7 @@ func (m crmdMeeting) StartHour() string { } func (m crmdMeeting) DurationHour() string { - return "12:30" + hour := m.Duration / 3600 + minute := (m.Duration % 3600) / 60 + return fmt.Sprintf("%02d:%02d", hour, minute) } diff --git a/spaEditMeeting.go b/spaEditMeeting.go index 209c39e..d46c7d4 100644 --- a/spaEditMeeting.go +++ b/spaEditMeeting.go @@ -148,8 +148,7 @@ func (m *crmdMeeting) validateFormInput(form url.Values) bool { starthour, hok := form["starthour"] duration, rok := form["duration"] if sok && hok && rok { - m.buildStartDate(startdate[0], starthour[0]) - m.buildDuration(duration[0]) + m.buildStartDate(startdate[0], starthour[0], duration[0]) } else { m.addSpaErr("活动日期,开始时间,持续时间 不能为空") } @@ -183,7 +182,7 @@ func (m *crmdMeeting) validateFormFile(r *http.Request) (ok bool) { return false } -func (m *crmdMeeting) buildStartDate(date, hour string) { +func (m *crmdMeeting) buildStartDate(date, hour, duration string) { layout := "2 January, 2006 15:04" value := strings.TrimSpace(date) + " " + strings.TrimSpace(hour) t, err := time.Parse(layout, value) @@ -193,6 +192,9 @@ func (m *crmdMeeting) buildStartDate(date, hour string) { } m.DateStart = t.Format(getCrmTimeLayout()) log.Println(m.DateStart) + + m.buildDuration(duration) + m.DateEnd = t.Add(time.Second * time.Duration(m.Duration)).Format(getCrmTimeLayout()) } func (m *crmdMeeting) buildDuration(duration string) {