Skip to content

Add timezone conversion in API serialization layer #124

@Besthope-Official

Description

@Besthope-Official

Use Case

Database stores UTC timestamps, but API responses should show times in user's timezone (e.g., UTC+8 for Asia/Shanghai).

Currently users see UTC times which appear 8 hours behind local time.

Proposed Solution

Implement timezone conversion in Pydantic serializers or middleware:

  • Read settings.app.timezone or user preferences
  • Convert UTC timestamps to target timezone in response models
  • Keep database storage in UTC

Implementation Notes

Use zoneinfo or pytz for timezone conversion.
Example: dt.astimezone(ZoneInfo('Asia/Shanghai'))

Related

Depends on reverting #88's database storage approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backend-enhancedbackend enhancementlong-termThis issue will be discussed over a long time

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions