Skip to content

Conversation

@lixiliu
Copy link
Collaborator

@lixiliu lixiliu commented Jan 16, 2026

Provides time zone localization support.

Integration into dsgrid: dsgrid/dsgrid#406

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces time zone localization functionality to handle conversion of timezone-naive (TIMESTAMP_NTZ) timestamps to timezone-aware (TIMESTAMP_TZ) timestamps. The changes include new localizer classes, refactoring of time configuration models, updates to test utilities, and bug fixes.

Changes:

  • Added TimeZoneLocalizer and TimeZoneLocalizerByColumn classes for localizing tz-naive timestamps to standard time zones
  • Refactored time configuration models to include dtype field and consolidated IndexTimeRange classes
  • Updated test utilities and fixed API inconsistencies (np.concatnp.concatenate)

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/chronify/time_zone_localizer.py New module implementing time zone localization classes and functions
src/chronify/time_configs.py Added dtype field to DatetimeRange classes and consolidated IndexTimeRange classes
src/chronify/time.py Replaced DatetimeFormat with TimeDataType enum
src/chronify/store.py Added localize_time_zone and localize_time_zone_by_column methods
src/chronify/time_zone_converter.py Updated error messages and added dtype field usage
src/chronify/datetime_range_generator.py Refactored timestamp generation to use pd.date_range and improved handling of time zones
src/chronify/sqlalchemy/functions.py Updated to use dtype field instead of start_time_is_tz_naive()
src/chronify/time_series_mapper_index_time.py Added dtype field assignment in mapping creation
src/chronify/time_series_checker.py Fixed typo in docstring
tests/test_time_zone_localizer.py Comprehensive test coverage for new localization functionality
tests/test_store.py Integration tests for localize_time_zone methods
tests/test_time_zone_converter.py Updated error message test and refactored test utilities
tests/test_mapper_*.py Refactored to use list_timestamps() instead of _iter_timestamps()
tests/test_mapper_column_representative_to_datetime.py Fixed np.concat → np.concatenate
src/chronify/init.py Updated exports to remove deprecated IndexTimeRange classes
docs/how_tos/map_time_config.md Fixed np.concat → np.concatenate in documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lixiliu lixiliu mentioned this pull request Jan 27, 2026
4 tasks
Copy link
Collaborator

@daniel-thom daniel-thom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; just some minor comments to clean up.

Note: Established time library already handles historical changes in time zone conversion to UTC.
(e.g. Algeria (Africa/Algiers) changed from UTC+0 to UTC+1 on April 25, 1980)
"""
for ts in self._list_timestamps(start=start):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are removing the feature of lazy iteration, we should remove this method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it needed for polymorism? All generators have this method and it is used by a mapper here:

def _iter_datetime(self) -> Generator[datetime, None, None]:
datetime_generator = DatetimeRangeGenerator(self._to_time_config)
yield from datetime_generator._iter_timestamps()

Copy link
Collaborator

@daniel-thom daniel-thom Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it needed for polymorism? All generators have this method and it is used by a mapper here:

def _iter_datetime(self) -> Generator[datetime, None, None]:
datetime_generator = DatetimeRangeGenerator(self._to_time_config)
yield from datetime_generator._iter_timestamps()

The base class only requires this method:

    @abc.abstractmethod
    def list_timestamps(self) -> list[Any]:

@lixiliu lixiliu requested a review from daniel-thom January 29, 2026 22:56
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.

3 participants