Skip to content

Normalize timestamps by stripping time zone offsets from Health data #3

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Polumm
Copy link

@Polumm Polumm commented Jun 14, 2025

Summary

This PR introduces a minimal, backwards-compatible patch to normalize Apple Health timestamps by stripping time zone offsets. It ensures compatibility with SQL TIMESTAMP WITHOUT TIME ZONE fields and resolves import issues on newer iOS exports (e.g., June 2025).

Changes

  • ✅ Added _strip_tz() helper in parse.py to clean creationDate, startDate, and endDate values
  • ✅ Updated parse.py to use the helper in the default record stream
  • ✅ Updated ActivitySummaryFormatter and SleepAnalysisFormatter in formatters.py to apply the same normalization
  • ✅ Handles malformed timestamps gracefully (logged and passed through)

Motivation

iOS-exported data may include time zone offsets (e.g., +0100), which are incompatible with the current database schema. This fix ensures consistent ingestion across older and newer data sets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant