timezone-adapter


Nametimezone-adapter JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/miguepoloc/timezone-adapter
SummaryA class for converting and manipulating datetime objects based on given timezone offset or name.
upload_time2024-12-15 21:44:18
maintainerNone
docs_urlNone
authorMiguel Angel Polo Castañeda
requires_python>=3.6
licenseMIT
keywords timezone datetime converter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TimeZoneAdapter

A Python library that provides an easy-to-use interface for converting and manipulating datetime objects across different time zones.

[![PyPI version](https://badge.fury.io/py/timezone-adapter.svg)](https://badge.fury.io/py/timezone-adapter)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python Versions](https://img.shields.io/pypi/pyversions/timezone-adapter.svg)](https://pypi.org/project/timezone-adapter/)

## Features

- Convert between time zones using numeric offset or timezone name
- Convert to and from UTC
- Calculate minimum and maximum dates for a specific day
- Support for both timezone offsets and timezone names (e.g., 'America/Bogota')
- Type hints support
- Zero dependencies (except pytz)

## Installation
```bash
pip install timezone-adapter
```

## Quick Start

```python
from datetime import datetime
from timezone_adapter import TimeZoneAdapter

# Using numeric offset (hours)
tz_adapter = TimeZoneAdapter(-5)  # UTC-5

# Using timezone name
tz_adapter = TimeZoneAdapter('America/Bogota')

# Convert to UTC
local_time = datetime.now()
utc_time = tz_adapter.to_utc(local_time)

# Get range of dates for today
min_date, max_date = tz_adapter.get_min_max_datetime_today()
```

## API Reference

### TimeZoneAdapter

#### `__init__(timezone: Union[int, str])`
Initialize with either a numeric offset (hours from UTC) or timezone name.

#### `to_utc(date_time: datetime) -> datetime`
Convert a local datetime to UTC.

#### `from_utc(date_time: datetime) -> datetime`
Convert a UTC datetime to local time.

#### `get_min_max_datetime_today() -> Tuple[datetime, datetime]`
Get the minimum and maximum datetime for the current day.

#### `get_min_max_datetime_by_date(date_time: datetime) -> Tuple[datetime, datetime]`
Get the minimum and maximum datetime for a specific date.

## Development

### Setup Development Environment

Clone the repository

```bash
git clone https://github.com/miguepoloc/timezone-adapter.git
cd timezone-adapter
```

Create and activate virtual environment

```bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```

Install development dependencies

```bash
pip install -e ".[dev]"
```

Run tests

```bash
pytest
```


### Code Quality

We use several tools to ensure code quality:

- `black` for code formatting
- `isort` for import sorting
- `mypy` for type checking
- `flake8` for style guide enforcement

Run all checks with:

```bash
pre-commit run --all-files
```


## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Author

Miguel Angel Polo Castañeda - [@miguepoloc](https://github.com/miguepoloc)

## Acknowledgments

- Thanks to the `pytz` library for timezone support
- Inspired by the need for simpler timezone handling in Python

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/miguepoloc/timezone-adapter",
    "name": "timezone-adapter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "timezone, datetime, converter",
    "author": "Miguel Angel Polo Casta\u00f1eda",
    "author_email": "Miguel Angel Polo Casta\u00f1eda <miguepoloc@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f5/3f/3cb6187e9a46c927d09a0b7614fac284fd887f12b79523306bfe87194406/timezone_adapter-0.1.0.tar.gz",
    "platform": null,
    "description": "# TimeZoneAdapter\n\nA Python library that provides an easy-to-use interface for converting and manipulating datetime objects across different time zones.\n\n[![PyPI version](https://badge.fury.io/py/timezone-adapter.svg)](https://badge.fury.io/py/timezone-adapter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python Versions](https://img.shields.io/pypi/pyversions/timezone-adapter.svg)](https://pypi.org/project/timezone-adapter/)\n\n## Features\n\n- Convert between time zones using numeric offset or timezone name\n- Convert to and from UTC\n- Calculate minimum and maximum dates for a specific day\n- Support for both timezone offsets and timezone names (e.g., 'America/Bogota')\n- Type hints support\n- Zero dependencies (except pytz)\n\n## Installation\n```bash\npip install timezone-adapter\n```\n\n## Quick Start\n\n```python\nfrom datetime import datetime\nfrom timezone_adapter import TimeZoneAdapter\n\n# Using numeric offset (hours)\ntz_adapter = TimeZoneAdapter(-5)  # UTC-5\n\n# Using timezone name\ntz_adapter = TimeZoneAdapter('America/Bogota')\n\n# Convert to UTC\nlocal_time = datetime.now()\nutc_time = tz_adapter.to_utc(local_time)\n\n# Get range of dates for today\nmin_date, max_date = tz_adapter.get_min_max_datetime_today()\n```\n\n## API Reference\n\n### TimeZoneAdapter\n\n#### `__init__(timezone: Union[int, str])`\nInitialize with either a numeric offset (hours from UTC) or timezone name.\n\n#### `to_utc(date_time: datetime) -> datetime`\nConvert a local datetime to UTC.\n\n#### `from_utc(date_time: datetime) -> datetime`\nConvert a UTC datetime to local time.\n\n#### `get_min_max_datetime_today() -> Tuple[datetime, datetime]`\nGet the minimum and maximum datetime for the current day.\n\n#### `get_min_max_datetime_by_date(date_time: datetime) -> Tuple[datetime, datetime]`\nGet the minimum and maximum datetime for a specific date.\n\n## Development\n\n### Setup Development Environment\n\nClone the repository\n\n```bash\ngit clone https://github.com/miguepoloc/timezone-adapter.git\ncd timezone-adapter\n```\n\nCreate and activate virtual environment\n\n```bash\npython -m venv .venv\nsource .venv/bin/activate # On Windows: .venv\\Scripts\\activate\n```\n\nInstall development dependencies\n\n```bash\npip install -e \".[dev]\"\n```\n\nRun tests\n\n```bash\npytest\n```\n\n\n### Code Quality\n\nWe use several tools to ensure code quality:\n\n- `black` for code formatting\n- `isort` for import sorting\n- `mypy` for type checking\n- `flake8` for style guide enforcement\n\nRun all checks with:\n\n```bash\npre-commit run --all-files\n```\n\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Author\n\nMiguel Angel Polo Casta\u00f1eda - [@miguepoloc](https://github.com/miguepoloc)\n\n## Acknowledgments\n\n- Thanks to the `pytz` library for timezone support\n- Inspired by the need for simpler timezone handling in Python\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A class for converting and manipulating datetime objects based on given timezone offset or name.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/miguepoloc/timezone-adapter",
        "Repository": "https://github.com/miguepoloc/timezone-adapter.git"
    },
    "split_keywords": [
        "timezone",
        " datetime",
        " converter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "43d92c2e71b9d7b9a3b0f493b40f5be307167114816234dd21c7441d550a9c70",
                "md5": "06a8648d57944ef9cac660ad8787d8ca",
                "sha256": "8ee0333dd0415cea9f94c5cfc8d9c04d414ba638cf7dd2223697ca50f4a580e5"
            },
            "downloads": -1,
            "filename": "timezone_adapter-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "06a8648d57944ef9cac660ad8787d8ca",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5109,
            "upload_time": "2024-12-15T21:44:16",
            "upload_time_iso_8601": "2024-12-15T21:44:16.091252Z",
            "url": "https://files.pythonhosted.org/packages/43/d9/2c2e71b9d7b9a3b0f493b40f5be307167114816234dd21c7441d550a9c70/timezone_adapter-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f53f3cb6187e9a46c927d09a0b7614fac284fd887f12b79523306bfe87194406",
                "md5": "a3f2493e8f89fd5af28ef4f597f9b554",
                "sha256": "55e3d544ecacf00b253f5167b870ef011a88bc825a0305f1a6b9833daf388f42"
            },
            "downloads": -1,
            "filename": "timezone_adapter-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a3f2493e8f89fd5af28ef4f597f9b554",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5103,
            "upload_time": "2024-12-15T21:44:18",
            "upload_time_iso_8601": "2024-12-15T21:44:18.587385Z",
            "url": "https://files.pythonhosted.org/packages/f5/3f/3cb6187e9a46c927d09a0b7614fac284fd887f12b79523306bfe87194406/timezone_adapter-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-15 21:44:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "miguepoloc",
    "github_project": "timezone-adapter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "timezone-adapter"
}
        
Elapsed time: 0.64672s