Python package for converting various units.
Project description
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.
-
- TimeModel
Installing
pip install unic
How to
- See the UserGuide.
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
Release history Release notifications | RSS feed
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.5.tar.gz
(6.8 kB
view details)
Built Distribution
unic-0.4.5-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file unic-0.4.5.tar.gz
.
File metadata
- Download URL: unic-0.4.5.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c030d94a7e4b5d4782cd9b5d48f04ddfd04c9fe644845fe93cf5cfd3baebd18 |
|
MD5 | 8b44743f1cb4023d19f1a45c97c88a6c |
|
BLAKE2b-256 | 75c0313ae12f28397dbfbb1ce6d4ad8b8a207c44a52a1919bd7cb863ba663c2c |
File details
Details for the file unic-0.4.5-py3-none-any.whl
.
File metadata
- Download URL: unic-0.4.5-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08d72264342619793194181f4b63f2c8d24c70ce58addb18959e718532a1f21a |
|
MD5 | bd75d1f790d315db5ad1acfa8d8da9c6 |
|
BLAKE2b-256 | 7e37b4d07ef100a6340be347340acc5e7c560a65a0aaf97496d0a784c5236211 |