Skip to content

fix: normalize mixed timezone datetime inputs #368

Description

@sudo-yf

Problem

Some MineContext code paths mix legacy local naive datetime strings with newer ISO8601 timestamps that include a Z suffix or explicit UTC offset.

One concrete path is screenshot ingestion: the desktop frontend can submit create_time as an ISO string, while backend processing and monitoring code still compares values against naive local datetime.now() values. When aware and naive datetimes meet in comparison-heavy logic, Python can raise:

TypeError: can't compare offset-naive and offset-aware datetimes

Expected behavior

Datetime inputs from API payloads, storage rows, and generated context objects should be normalized before comparison so screenshot ingestion, vault scanning, processing, and scheduled consumption tasks can handle both legacy local strings and ISO8601 Z/offset strings.

Proposed fix

Normalize incoming datetime-like values to local naive datetime objects at the boundaries where they enter existing comparison logic, preserving compatibility with the current codebase's naive-local assumptions.

Related PR

Fix proposed in #367.

Verification from PR

  • python3 -m unittest tests/test_datetime_normalization.py
  • python3 -m py_compile opencontext/utils/datetime_utils.py opencontext/context_capture/vault_document_monitor.py opencontext/context_consumption/generation/smart_tip_generator.py opencontext/context_processing/processor/screenshot_processor.py opencontext/managers/consumption_manager.py opencontext/server/context_operations.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions