INNER CODE UNIT · Go

FmtExpires

GGP1/kure · commands/util.go:213

func FmtExpires(expires string) (string, error) {
	switch strings.ToLower(expires) {
	case "never", "", " ", "0", "0s":
		return "Never", nil

	default:
		expires = strings.ReplaceAll(expires, "-", "/")

		// If the first format fails, try the second
		exp, err := time.Parse("02/01/2006", expires)
		if err != nil {
			exp, err = time.Parse("2006/01/02", expires)
			if err != nil {
				return "", errors.New("\"expires\" field has an invalid format. Valid formats: d/m/y or y/m/d")
			}
		}

		return exp.Format(time.RFC1123Z), nil

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…