larksuite/cli · error
cannot parse time %q (supported: ISO 8601 e.g. 2026-01-01 /
Error message
cannot parse time %q (supported: ISO 8601 e.g. 2026-01-01 / 2026-01-01T15:04:05+08:00, Unix timestamp)
What it means
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.
Source
Thrown at shortcuts/common/common.go:91
"2006-01-02 15:04:05",
"2006-01-02T15:04",
"2006-01-02 15:04",
}
for _, f := range preciseFormats {
if t, err := time.ParseInLocation(f, input, time.Local); err == nil {
return fmt.Sprintf("%d", t.Unix()), nil
}
}
// Date-only (day-granularity)
if t, err := time.ParseInLocation("2006-01-02", input, time.Local); err == nil {
return fmt.Sprintf("%d", snapDay(t).Unix()), nil
}
// Unix timestamp (precise, passed through as-is) — must be purely numeric
var ts int64
if n, err := fmt.Sscanf(input, "%d", &ts); err == nil && n == 1 && ts > 0 && fmt.Sprintf("%d", ts) == input {
return input, nil
}
return "", fmt.Errorf("cannot parse time %q (supported: ISO 8601 e.g. 2026-01-01 / 2026-01-01T15:04:05+08:00, Unix timestamp)", input)
}
// FormatTimeWithSeconds converts Unix seconds/ms string to local time string with seconds precision.
func FormatTimeWithSeconds(ts interface{}) string {
if ts == nil {
return ""
}
s := fmt.Sprintf("%v", ts)
if s == "" {
return ""
}
var n int64
fmt.Sscanf(s, "%d", &n)
if n == 0 {
return s
}
if n > 1e12 {
n = n / 1000View on GitHub (pinned to 7fd6ef3c07)
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
Example fix
// before --from 01/02/2026 // after --from 2026-01-02
Defensive patterns
Strategy: validation
Validate before calling
func validTimeArg(s string) bool {
if _, err := time.Parse("2006-01-02", s); err == nil { return true }
if _, err := time.Parse(time.RFC3339, s); err == nil { return true }
n, err := strconv.ParseInt(s, 10, 64)
return err == nil && n > 0 && strconv.FormatInt(n, 10) == s
} Try / catch
if strings.Contains(err.Error(), "cannot parse time") {
// normalize the value to ISO 8601 or Unix seconds before retrying
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid column: {column!r}
- Invalid column index: {index}
- anchor outside sheet: {position!r}
- Missing row_count/column_count for sheet {sheet_title(sheet)
- Missing sheet_id for sheet {title!r}
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/0c8681ba45851823.
Report an issue: GitHub.