{"record":{"id":"0c8681ba45851823","repo":"larksuite/cli","slug":"cannot-parse-time-q-supported-iso-8601-e-g-202","errorCode":null,"errorMessage":"cannot parse time %q (supported: ISO 8601 e.g. 2026-01-01 / 2026-01-01T15:04:05+08:00, Unix timestamp)","messagePattern":"cannot parse time %q \\(supported: ISO 8601 e\\.g\\. 2026-01-01 / 2026-01-01T15:04:05\\+08:00, Unix timestamp\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/common.go","lineNumber":91,"sourceCode":"\t\t\"2006-01-02 15:04:05\",\n\t\t\"2006-01-02T15:04\",\n\t\t\"2006-01-02 15:04\",\n\t}\n\tfor _, f := range preciseFormats {\n\t\tif t, err := time.ParseInLocation(f, input, time.Local); err == nil {\n\t\t\treturn fmt.Sprintf(\"%d\", t.Unix()), nil\n\t\t}\n\t}\n\t// Date-only (day-granularity)\n\tif t, err := time.ParseInLocation(\"2006-01-02\", input, time.Local); err == nil {\n\t\treturn fmt.Sprintf(\"%d\", snapDay(t).Unix()), nil\n\t}\n\t// Unix timestamp (precise, passed through as-is) — must be purely numeric\n\tvar ts int64\n\tif n, err := fmt.Sscanf(input, \"%d\", &ts); err == nil && n == 1 && ts > 0 && fmt.Sprintf(\"%d\", ts) == input {\n\t\treturn input, nil\n\t}\n\treturn \"\", fmt.Errorf(\"cannot parse time %q (supported: ISO 8601 e.g. 2026-01-01 / 2026-01-01T15:04:05+08:00, Unix timestamp)\", input)\n}\n\n// FormatTimeWithSeconds converts Unix seconds/ms string to local time string with seconds precision.\nfunc FormatTimeWithSeconds(ts interface{}) string {\n\tif ts == nil {\n\t\treturn \"\"\n\t}\n\ts := fmt.Sprintf(\"%v\", ts)\n\tif s == \"\" {\n\t\treturn \"\"\n\t}\n\tvar n int64\n\tfmt.Sscanf(s, \"%d\", &n)\n\tif n == 0 {\n\t\treturn s\n\t}\n\tif n > 1e12 {\n\t\tn = n / 1000","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/common.go#L73-L109","documentation":"ParseTime accepts ISO 8601 (date or datetime with optional offset) or a pure-numeric positive Unix timestamp; anything else fails with this message listing the supported forms. It is the shared time parser for calendar/freebusy/search/room-suggestion commands.","triggerScenarios":"Passing a value like '01/02/2026', 'yesterday', '2026-13-45', a negative or non-canonical timestamp ('+123', '1e9'), or a datetime with unsupported formatting to flags consumed by parseTimeRange/parseFreebusyTimeRange/parseRoomFindSlots/parseSearchEventTimeRange/buildSuggestionRequest.","commonSituations":"US-style MM/DD/YYYY dates, natural language times, timestamps with milliseconds ('1700000000000' fails the round-trip Sscanf check), or locale-formatted dates pasted from other tools.","solutions":["Use ISO 8601: 2026-01-01 or 2026-01-01T15:04:05+08:00","Use a plain positive Unix-seconds timestamp with no sign, spaces, or leading zeros (e.g. 1767225600)","Convert first: date -d '01/02/2026' +%s, or for ms timestamps divide by 1000","Use '-' or now-style shortcuts only if the specific command documents them; otherwise stick to ISO 8601"],"exampleFix":"// before\n--from 01/02/2026\n// after\n--from 2026-01-02\n","handlingStrategy":"validation","validationCode":"func validTimeArg(s string) bool {\n\tif _, err := time.Parse(\"2006-01-02\", s); err == nil { return true }\n\tif _, err := time.Parse(time.RFC3339, s); err == nil { return true }\n\tn, err := strconv.ParseInt(s, 10, 64)\n\treturn err == nil && n > 0 && strconv.FormatInt(n, 10) == s\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"cannot parse time\") {\n\t// normalize the value to ISO 8601 or Unix seconds before retrying\n}","preventionTips":["Always pass ISO 8601 dates/datetimes or plain Unix-seconds strings","Convert locale dates (e.g. MM/DD/YYYY) with `date -d ... +%s` before use","Avoid millisecond timestamps and values with signs, spaces, or leading zeros"],"tags":["time-parsing","cli-input","validation"],"backgroundTag":"invalid-time-format","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}