Skip to content

bakhshipoor/TimeZone

Repository files navigation

TimeZone Library


Time zone library for embedded systems

This library is composed of two main parts:

Part 1: TimeZoneDatabaseCreator

This part is designed for use on Windows with Visual Studio 2022. It allows you to convert the time zone database from https://www.iana.org/time-zones into a format suitable for embedded systems.

Steps:

  1. Download the compressed database file from the IANA website. It is recommended to download the "Data Only Distribution" option.
  2. Extract the downloaded file.
  3. Provide the path to the extracted files to the TimeZoneDatabaseCreator application.
  4. The application will process the data and create a folder named timezone_database within your project directory. This folder will contain the following six files:
    • timezone_database.h: Defines the necessary structures, variables, and constants.
    • timezone_database.c: Contains the compiled time zone database for efficient use in your embedded firmware. This file is optimized for performance and speed.
    • tz_zi.txt: Contains time zone index information.
    • tz_zd.txt: Contains time zone data.
    • tz_ri.txt: Contains rule index information.
    • tz_rd.txt: Contains rule data.

Part 2: TimeZoneCalculator

This part provides functions for calculating and converting time between Greenwich Mean Time (GMT) or Coordinated Universal Time (UTC) and local time for any given date and time.

Functionality:

You provide the desired date, time, and time zone code to the TimeZoneCalculator library, and it returns the corresponding local time.

Structure:

This part consists of two components:

  1. timezone_database: This is the same folder generated by the TimeZoneDatabaseCreator in Part 1. It needs to be copied into the TimeZoneCalculator directory.
  2. timezone_calculator: This component contains the functions responsible for time calculations.

Usage:

To use the TimeZoneCalculator, include the time_zone.h file in your project.

Example:

For usage examples and to understand how the functions work, refer to the test.c file located in the TimeZoneCalculator folder.

Additional Information

Disclaimer: This library is under active development and may contain bugs or limitations.