Skip to main content

Python package for converting various units.

Project description

Python minimum version pytest black

unic

unic is a python package that can convert various units.

Conversion Targets

  • The current available conversion targets are as follows.

    Time Unit
    • 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
    Length Unit
    • 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.

Installing

pip install unic

How to

Example

Time Unit

TimeModel

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

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

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

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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unic-1.3.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

unic-1.3.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file unic-1.3.0.tar.gz.

File metadata

  • Download URL: unic-1.3.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.1 Windows/10

File hashes

Hashes for unic-1.3.0.tar.gz
Algorithm Hash digest
SHA256 891c79623ade38fd9a3c6ebeb03c6b95ba24fbe93272cba98d886dafda9c3782
MD5 9c4878c9a6be73f22ee42e85d8b05f98
BLAKE2b-256 3c0369e40070dd717c242caa1712ca4c48203ee4c5778b0beb0a0e49d48585cd

See more details on using hashes here.

File details

Details for the file unic-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: unic-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.1 Windows/10

File hashes

Hashes for unic-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2d1732dfa65feafbbd65fdd76bf9832b3f7186f2b9ebae56b35759a7fcb1005
MD5 e27b983c3e4ea1fbe68988e50dbc7e2d
BLAKE2b-256 b06e6f95e0e816b4e55fe2f2e4d43c49b2c99456c0a9cf50efd01d5294648804

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page