{"record":{"id":"8e18803bf6515ca3","repo":"larksuite/cli","slug":"expected-rfc3339-yyyy-mm-dd-hh-mm-ss-or-unix-s","errorCode":null,"errorMessage":"expected RFC3339, YYYY-MM-DD[ HH:MM:SS], or unix seconds","messagePattern":"expected RFC3339, YYYY-MM-DD\\[ HH:MM:SS\\], or unix seconds","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/doc/docs_search.go","lineNumber":263,"sourceCode":"}\n\nfunc toUnixSeconds(input string) (int64, error) {\n\tformats := []string{\n\t\ttime.RFC3339,\n\t\t\"2006-01-02T15:04:05\",\n\t\t\"2006-01-02 15:04:05\",\n\t\t\"2006-01-02\",\n\t}\n\tfor _, f := range formats {\n\t\tif t, err := time.ParseInLocation(f, input, time.Local); err == nil {\n\t\t\treturn t.Unix(), nil\n\t\t}\n\t}\n\t// Try as number\n\tif n, err := strconv.ParseInt(input, 10, 64); err == nil {\n\t\treturn n, nil\n\t}\n\treturn 0, fmt.Errorf(\"expected RFC3339, YYYY-MM-DD[ HH:MM:SS], or unix seconds\") //nolint:forbidigo // intermediate parse helper; caller wraps into typed ValidationError\n}\n\nfunc unixTimestampToISO8601(v interface{}) string {\n\tif v == nil {\n\t\treturn \"\"\n\t}\n\n\tvar num float64\n\tswitch val := v.(type) {\n\tcase float64:\n\t\tnum = val\n\tcase json.Number:\n\t\tparsed, err := val.Float64()\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\tnum = parsed\n\tcase string:","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/doc/docs_search.go#L245-L281","documentation":"toUnixSeconds parses --filter time-range values (e.g. create_time.start) and accepts RFC3339, YYYY-MM-DD, YYYY-MM-DD HH:MM:SS, and plain unix seconds. When none of those formats (nor integer parsing) matches, it returns this message, which the caller wraps in a typed ValidationError naming the offending key and value.","triggerScenarios":"Passing a value like '2026/09/04', '09-04-2026', 'yesterday', 'now-1d', an empty-string date part, or a float timestamp ('1756944000.5') in a filter time field.","commonSituations":"Copy-pasting human-formatted dates from spreadsheets or locale formats (MM/DD/YYYY); using relative time expressions that are not supported; including timezone names like 'UTC' that Go's RFC3339 parser rejects.","solutions":["Use RFC3339 with offset: 2026-09-04T00:00:00+08:00.","Or use a plain date 2026-09-04 (optionally with 15:04:05 time) or bare unix seconds like 1756944000.","Compute relative ranges yourself (e.g. with date -d '-1 day' +%s) and pass the resulting unix seconds."],"exampleFix":"// before\nlark-cli doc search --filter '{\"create_time\":{\"start\":\"yesterday\"}}'\n// after\nlark-cli doc search --filter '{\"create_time\":{\"start\":\"2026-09-03T00:00:00+08:00\"}}'","handlingStrategy":"validation","validationCode":"# Validate the timestamp before invoking:\ndate -j -f \"%Y-%m-%dT%H:%M:%S%z\" \"2026-09-04T00:00:00+0800\" \"+%s\" || echo \"use RFC3339, YYYY-MM-DD[ HH:MM:SS], or unix seconds\"","typeGuard":"func validTimeRangeValue(s string) bool {\n    formats := []string{time.RFC3339, \"2006-01-02\", \"2006-01-02 15:04:05\"}\n    for _, f := range formats {\n        if _, err := time.ParseInLocation(f, s, time.Local); err == nil {\n            return true\n        }\n    }\n    _, err := strconv.ParseInt(s, 10, 64)\n    return err == nil\n}","tryCatchPattern":"// Callers should surface the typed ValidationError including the offending value:\nif _, err := toUnixSeconds(v); err != nil {\n    return errs.NewValidationError(errs.SubtypeInvalidArgument, \"invalid %s %q: %s\", key, v, err)\n}","preventionTips":["Always use one of: RFC3339 with numeric offset, YYYY-MM-DD, YYYY-MM-DD HH:MM:SS, or integer unix seconds.","Avoid relative expressions ('yesterday', 'now-1d') and float timestamps — compute them to unix seconds first.","Include the timezone offset explicitly; bare 'Z'-less times without offset may fail RFC3339 parsing."],"tags":["cli","date-parsing","filter","validation","user-input"],"backgroundTag":"invalid-date-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"}