MCPcopy
hub / github.com/robfig/cron / getTime

Function getTime

spec_test.go:217–246  ·  spec_test.go::getTime
(value string)

Source from the content-addressed store, hash-verified

215}
216
217func getTime(value string) time.Time {
218 if value == "" {
219 return time.Time{}
220 }
221
222 var location = time.Local
223 if strings.HasPrefix(value, "TZ=") {
224 parts := strings.Fields(value)
225 loc, err := time.LoadLocation(parts[0][len("TZ="):])
226 if err != nil {
227 panic("could not parse location:" + err.Error())
228 }
229 location = loc
230 value = parts[1]
231 }
232
233 var layouts = []string{
234 "Mon Jan 2 15:04 2006",
235 "Mon Jan 2 15:04:05 2006",
236 }
237 for _, layout := range layouts {
238 if t, err := time.ParseInLocation(layout, value, location); err == nil {
239 return t
240 }
241 }
242 if t, err := time.ParseInLocation("2006-01-02T15:04:05-0700", value, location); err == nil {
243 return t
244 }
245 panic("could not parse time value " + value)
246}
247
248func TestNextWithTz(t *testing.T) {
249 runs := []struct {

Callers 3

TestActivationFunction · 0.85
TestNextFunction · 0.85
TestConstantDelayNextFunction · 0.85

Calls 1

ErrorMethod · 0.65

Tested by

no test coverage detected