Skip to main content

Python minimum version Test-pytest Format-Ruff Lint-Ruff

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:ss
    • yyyy/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 use convert() with a list instead.
  • If unit is omitted in UnixtimeModel, the default is sec.

Documentation

  • See docs/UserGuide.md
  • Add future pages:
    • docs/QuickStart.md
    • docs/SupportedConversions.md
    • docs/FAQ.md
    • docs/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)

Source distribution for unic 3.0.0
File Size Uploaded
unic-3.0.0.tar.gz 56.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unic 3.0.0
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page