unic


Nameunic JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttps://github.com/subretu/unic
SummaryPython package for converting various units.
upload_time2024-11-12 15:50:40
maintainerSubretu
docs_urlNone
authorSubretu
requires_python<4.0,>=3.9
licenseMIT
keywords unit convert time timestamp length
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Python minimum version](https://img.shields.io/badge/Python-3.9%2B-brightgreen)
[![pytest](https://github.com/subretu/unic/actions/workflows/pytest.yml/badge.svg)](https://github.com/subretu/unic/actions/workflows/pytest.yml)
[![black](https://github.com/subretu/unic/actions/workflows/format.yml/badge.svg)](https://github.com/subretu/unic/actions/workflows/format.yml)

# unic
  `unic` is a python package that can convert various units.

## Conversion Targets
- The current available conversion targets are as follows.

  <details>
  <summary>Time Unit</summary>

    - TimeModel
      - minute / second / milisecond → hour
      - hour / second / milisecond → minute
      - hour / minute / milisecond → second
      - hour / minute / second → milisecond
    - DatetimeModel
      - unixtime / unixtime+timezone → datetime.datetime
      - unixtime / unixtime+timezone → datetime.date
    - UnixtimeModel
      - string(yyyy-mm-dd hh:mm:ss) / string(yyyy-mm-dd hh:mm:ss)+timezone → unixtime
      - string(yyyy/mm/dd hh:mm:ss) / string(yyyy/mm/dd hh:mm:ss)+timezone → unixtime
  </details>

  <details>
  <summary>Length Unit</summary>

    - MetricSystemModel
      -  Target Metric System Units

         ```
         nm, um, mm, cm, m, km, Mm, Gm, Tm
         ```
         ※ um : represents ㎛.
       -  The target metric system units are can be converted to each other.

  </details>

## Installing

  ```
  pip install unic
  ```

## How to
- See the [UserGuide](docs/UserGuide.md).

## Example
### Time Unit
#### TimeModel

```python
import unic


convert_model = unic.load_model("time")
# Convert hour to minute
convert_min = convert_model.convert(2, from_unit="hour", to_unit="min")
# Convert hour to minute (batch processing)
convert_min = convert_model.convert_batch([2,4,6], from_unit="hour", to_unit="min")
```

#### DatetimeModel

```python
import unic


convert_model = unic.load_model("datetime")
# Convert to datatime
convert_datetime = convert_model.convert(1577841753, format="datetime")
# Convert to datatime (batch processing)
convert_datetime = convert_model.convert_batch([1577841753,1577941753], format="datetime")

# Convert to date
convert_datetime = convert_model.convert(1577841753, format="date")
```

#### UnixtimeModel

```python
import unic


convert_model = unic.load_model("unixtime")
# Specify time zone
convert_unixtime = convert_model.convert("2023-05-12 10:15:20", tz="Asia/Tokyo")
# Specify time zone (batch processing)
convert_unixtime = convert_model.convert_batch(["2023-05-12 10:15:20","2023-05-13 10:15:20","2023-05-14 10:15:20"], tz="Asia/Tokyo")
```

### Length Unit
#### MetricSystemModel

```python
import unic


convert_model = unic.load_model("metric_system")
# Convert cm to m
convert_m = convert_model.convert(20, from_unit="cm", to_unit="m")
# Convert cm to m (batch processing)
convert_m = convert_model.convert_batch([20,50,100,200], from_unit="cm", to_unit="m")
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/subretu/unic",
    "name": "unic",
    "maintainer": "Subretu",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "unit, convert, time, timestamp, length",
    "author": "Subretu",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/3c/03/69e40070dd717c242caa1712ca4c48203ee4c5778b0beb0a0e49d48585cd/unic-1.3.0.tar.gz",
    "platform": null,
    "description": "![Python minimum version](https://img.shields.io/badge/Python-3.9%2B-brightgreen)\n[![pytest](https://github.com/subretu/unic/actions/workflows/pytest.yml/badge.svg)](https://github.com/subretu/unic/actions/workflows/pytest.yml)\n[![black](https://github.com/subretu/unic/actions/workflows/format.yml/badge.svg)](https://github.com/subretu/unic/actions/workflows/format.yml)\n\n# unic\n  `unic` is a python package that can convert various units.\n\n## Conversion Targets\n- The current available conversion targets are as follows.\n\n  <details>\n  <summary>Time Unit</summary>\n\n    - TimeModel\n      - minute / second / milisecond \u2192 hour\n      - hour / second / milisecond \u2192 minute\n      - hour / minute / milisecond \u2192 second\n      - hour / minute / second \u2192 milisecond\n    - DatetimeModel\n      - unixtime / unixtime+timezone \u2192 datetime.datetime\n      - unixtime / unixtime+timezone \u2192 datetime.date\n    - UnixtimeModel\n      - string(yyyy-mm-dd hh:mm:ss) / string(yyyy-mm-dd hh:mm:ss)+timezone \u2192 unixtime\n      - string(yyyy/mm/dd hh:mm:ss) / string(yyyy/mm/dd hh:mm:ss)+timezone \u2192 unixtime\n  </details>\n\n  <details>\n  <summary>Length Unit</summary>\n\n    - MetricSystemModel\n      -  Target Metric System Units\n\n         ```\n         nm, um, mm, cm, m, km, Mm, Gm, Tm\n         ```\n         \u203b um : represents \u339b.\n       -  The target metric system units are can be converted to each other.\n\n  </details>\n\n## Installing\n\n  ```\n  pip install unic\n  ```\n\n## How to\n- See the [UserGuide](docs/UserGuide.md).\n\n## Example\n### Time Unit\n#### TimeModel\n\n```python\nimport unic\n\n\nconvert_model = unic.load_model(\"time\")\n# Convert hour to minute\nconvert_min = convert_model.convert(2, from_unit=\"hour\", to_unit=\"min\")\n# Convert hour to minute (batch processing)\nconvert_min = convert_model.convert_batch([2,4,6], from_unit=\"hour\", to_unit=\"min\")\n```\n\n#### DatetimeModel\n\n```python\nimport unic\n\n\nconvert_model = unic.load_model(\"datetime\")\n# Convert to datatime\nconvert_datetime = convert_model.convert(1577841753, format=\"datetime\")\n# Convert to datatime (batch processing)\nconvert_datetime = convert_model.convert_batch([1577841753,1577941753], format=\"datetime\")\n\n# Convert to date\nconvert_datetime = convert_model.convert(1577841753, format=\"date\")\n```\n\n#### UnixtimeModel\n\n```python\nimport unic\n\n\nconvert_model = unic.load_model(\"unixtime\")\n# Specify time zone\nconvert_unixtime = convert_model.convert(\"2023-05-12 10:15:20\", tz=\"Asia/Tokyo\")\n# Specify time zone (batch processing)\nconvert_unixtime = convert_model.convert_batch([\"2023-05-12 10:15:20\",\"2023-05-13 10:15:20\",\"2023-05-14 10:15:20\"], tz=\"Asia/Tokyo\")\n```\n\n### Length Unit\n#### MetricSystemModel\n\n```python\nimport unic\n\n\nconvert_model = unic.load_model(\"metric_system\")\n# Convert cm to m\nconvert_m = convert_model.convert(20, from_unit=\"cm\", to_unit=\"m\")\n# Convert cm to m (batch processing)\nconvert_m = convert_model.convert_batch([20,50,100,200], from_unit=\"cm\", to_unit=\"m\")\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python package for converting various units.",
    "version": "1.3.0",
    "project_urls": {
        "Homepage": "https://github.com/subretu/unic",
        "Repository": "https://github.com/subretu/unic"
    },
    "split_keywords": [
        "unit",
        " convert",
        " time",
        " timestamp",
        " length"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b06e6f95e0e816b4e55fe2f2e4d43c49b2c99456c0a9cf50efd01d5294648804",
                "md5": "e27b983c3e4ea1fbe68988e50dbc7e2d",
                "sha256": "c2d1732dfa65feafbbd65fdd76bf9832b3f7186f2b9ebae56b35759a7fcb1005"
            },
            "downloads": -1,
            "filename": "unic-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e27b983c3e4ea1fbe68988e50dbc7e2d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 12251,
            "upload_time": "2024-11-12T15:50:38",
            "upload_time_iso_8601": "2024-11-12T15:50:38.609073Z",
            "url": "https://files.pythonhosted.org/packages/b0/6e/6f95e0e816b4e55fe2f2e4d43c49b2c99456c0a9cf50efd01d5294648804/unic-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c0369e40070dd717c242caa1712ca4c48203ee4c5778b0beb0a0e49d48585cd",
                "md5": "9c4878c9a6be73f22ee42e85d8b05f98",
                "sha256": "891c79623ade38fd9a3c6ebeb03c6b95ba24fbe93272cba98d886dafda9c3782"
            },
            "downloads": -1,
            "filename": "unic-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9c4878c9a6be73f22ee42e85d8b05f98",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 7916,
            "upload_time": "2024-11-12T15:50:40",
            "upload_time_iso_8601": "2024-11-12T15:50:40.247546Z",
            "url": "https://files.pythonhosted.org/packages/3c/03/69e40070dd717c242caa1712ca4c48203ee4c5778b0beb0a0e49d48585cd/unic-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-12 15:50:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "subretu",
    "github_project": "unic",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "unic"
}
        
Elapsed time: 0.54670s