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

DatetimeModel

import unic


convert_model = unic.load_model("datetime")
# Convert to datatime
convert_datetime = convert_model.convert(1577841753, 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")

Length Unit

MetricSystemModel

import unic


convert_model = unic.load_model("metric_system")
# Convert cm to m
convert_min = convert_model.convert(20, 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-0.4.4.tar.gz (7.0 kB view hashes)

Uploaded Source

Built Distribution

unic-0.4.4-py3-none-any.whl (9.7 kB view hashes)

Uploaded Python 3

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