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

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

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.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

unic-0.4.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unic-0.4.0.tar.gz
  • Upload date:
  • Size: 6.6 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-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e1b10adaad2b37677de7754c86829b89f3d0c10ad16d3610eeeb04130b016804
MD5 a10bffea4b3e252e90b8c6dbe5b14caf
BLAKE2b-256 e3e61b2f437e23d541aaa4c56234a1e944246a8178b99ea5f1e392ed3ff6327a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: unic-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4825467c861eaf646a3d4a5137641c67b8ca50889304f988b0f8ce600da7809
MD5 95b514ec2d6c05141d6a2cc834d404a7
BLAKE2b-256 8f1eb6f8647f7d0898302735dacf8a3f99feb50e4faecd65062c495994c40dfc

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