unic
unic is a lightweight Python library for time unit conversions and Unix timestamp conversions:
- time units (
hour,min,sec,msec) - Unix timestamps to
datetime/date - datetime strings to Unix timestamps
It is designed for simple scripting, data processing, analytics, and timestamp handling.
Installation
pip install unic
Quick Start
import unic
# Time conversion
time_model = unic.load_model("time")
print(time_model.convert(2, from_unit="hour", to_unit="min")) # 120
# Unixtime -> datetime
datetime_model = unic.load_model("datetime")
print(datetime_model.convert(1657985494, format="datetime"))
# String datetime -> unixtime
unixtime_model = unic.load_model("unixtime")
print(unixtime_model.convert("2022-07-18 13:49:00", tz="Asia/Tokyo"))
Supported Conversions
TimeModel
hour/min/sec/msec
DatetimeModel
- unixtime ->
datetime.datetime - unixtime ->
datetime.date
UnixtimeModel
- datetime string -> unixtime
- supported formats:
yyyy-mm-dd hh:mm:ssyyyy/mm/dd hh:mm:ss
Examples
Convert a single value
import unic
model = unic.load_model("time")
result = model.convert(7.5, from_unit="hour", to_unit="min")
print(result) # 450
Convert a list of values
import unic
model = unic.load_model("time")
result = model.convert([2, 4, 6], from_unit="hour", to_unit="min")
print(result) # [120, 240, 360]
Convert unixtime to datetime
import unic
model = unic.load_model("datetime")
result = model.convert(1657985494, format="datetime", tz="Asia/Tokyo")
print(result)
Convert datetime string to unixtime
import unic
model = unic.load_model("unixtime")
result = model.convert("2022-07-18 13:49:00.123", unit="msec")
print(result)
Notes
convert()supports both single values and lists.convert_batch()is deprecated. Please useconvert()with a list instead.- If
unitis omitted inUnixtimeModel, the default issec.
Documentation
- See
docs/UserGuide.md - Add future pages:
docs/QuickStart.mddocs/SupportedConversions.mddocs/FAQ.mddocs/MigrationGuide.md
Why unic?
- Simple API
- Lightweight package
- Supports list conversion
- Supports timezone-aware conversion
- Tested with multiple Python versions
License
MIT
Metadata
Release files for unic 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| unic-3.0.0.tar.gz | 56.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| unic-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 68.1 kB
Release files / unic-3.0.0.tar.gz
| Download URL | unic-3.0.0.tar.gz |
|---|---|
| Size | 56.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d05219f67f931a45228ba911b6d185d20bf38fa4a39e37cbe4351e9d6ef842cd
|
|
BLAKE2b-256 checksum How to use checksums |
6c00f05a15500908b04289fc69517f85c1883e6cac789aa5bdc49878763a14a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency logRelease files / unic-3.0.0-py3-none-any.whl
| Download URL | unic-3.0.0-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9590741d8fe6393c58f9912e7b4647a47327bd2d6c966a2ea79276f12ebaf210
|
|
BLAKE2b-256 checksum How to use checksums |
f1abd0461734bc6214f5aaf607fadc4fd6230ca2498f7816c1553c13ae0e14f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency log