Skip to content

feat: add support for TimeDelta type in Python and Rust #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/core/data_types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This is the list of all basic types supported by CocoIndex:
| Time | | `datetime.time` | `datetime.time` |
| LocalDatetime | Date and time without timezone | `cocoindex.LocalDateTime` | `datetime.datetime` |
| OffsetDatetime | Date and time with a timezone offset | `cocoindex.OffsetDateTime` | `datetime.datetime` |
| TimeDelta | A duration of time | `datetime.timedelta` | `datetime.timedelta` |
| Vector[*T*, *Dim*?] | *T* must be basic type. *Dim* is a positive integer and optional. |`cocoindex.Vector[T]` or `cocoindex.Vector[T, Dim]` | `list[T]` |
| Json | | `cocoindex.Json` | Any data convertible to JSON by `json` package |

Expand Down
2 changes: 2 additions & 0 deletions python/cocoindex/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def analyze_type_info(t) -> AnalyzedTypeInfo:
kind = 'Time'
elif t is datetime.datetime:
kind = 'OffsetDateTime'
elif t is datetime.timedelta:
kind = 'TimeDelta'
else:
raise ValueError(f"type unsupported yet: {t}")

Expand Down
Loading