Alphabetic Timestamp
This is small Python package which encode standard timestamp to shorted form by using alphabetic symbols.
Installation
pip install alphabetic-timestamp
Description
User can use two base for coding. It other words two different lists of symbols for encoding.
-
Base36
-
Base62
Example of coding
This example show coding of datetime 2020-01-01 20:20:20.002000. It means timestamp 1577906420.002.
| Time Units | Base36 | Base62 |
|---|---|---|
| seconds | q3g0dw | 1IMJxy |
| deciseconds | 78yg3uw | hdRlpu |
| centiseconds | 20hkh2kw | 2MeBs6Q |
| milliseconds | k4voqpsy | rMm2x6q |
Symbols of Base 36
import alphabetic_timestamp as ats
print(ats.base36.symbols)
>>> 0123456789abcdefghijklmnopqrstuvwxyz
Symbols of Base 62
import alphabetic_timestamp as ats
print(ats.base62.symbols)
>>> 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Interface
The example shows interface of base36. The interface is same for base62.
import datetime
import alphabetic_timestamp as ats
dt = datetime.datetime.now()
ts = dt.timestamp()
ats.base36.now(time_unit=ats.TimeUnit.seconds)
ats.base36.from_datetime(dt, time_unit=ats.TimeUnit.seconds)
ats.base36.from_timestamp(ts, time_unit=ats.TimeUnit.seconds)
ats.base36.to_datetime("q67vhw", time_unit=ats.TimeUnit.seconds, time_zone=None)
ats.base36.to_timestamp("q67vhw", time_unit=ats.TimeUnit.seconds)
Note: The string "q67vhw" is only example of encoded timestamp.
Examples
This package is compatible with Python2.7 and Python3.4+. However these examples are written in Python3.6.
Encode & Print
import alphabetic_timestamp as ats
print(ats.base36.now())
# Current DT: 2020-02-24 18:34:44.349162
>>> q67vhw
Encoded & Decode
import datetime
import alphabetic_timestamp as ats
# DATETIME -> ALPHABETIC_TIMESTAMP -> DATETIME
dt = datetime.datetime.now()
alphabetic_ts_36 = ats.base36.from_datetime(dt)
decoded_ts_36 = ats.base36.to_datetime(alphabetic_ts_36)
alphabetic_ts_62 = ats.base62.from_datetime(dt)
decoded_ts_62 = ats.base62.to_datetime(alphabetic_ts_62)
# TIMESTAMP -> ALPHABETIC_TIMESTAMP -> TIMESTAMP
ts = dt.timestamp()
alphabetic_ts_36 = ats.base36.from_timestamp(ts)
decoded_ts_36 = ats.base36.to_timestamp(alphabetic_ts_36)
alphabetic_ts_62 = ats.base62.from_timestamp(ts)
decoded_ts_62 = ats.base62.to_timestamp(alphabetic_ts_62)
Time units
import datetime
import alphabetic_timestamp as ats
dt = datetime.datetime.now()
# Set time unit for current timestamp
now36_ts = ats.base36.now() # default: ats.TimeUnit.seconds
now36_ts = ats.base36.now(time_unit=ats.TimeUnit.seconds)
# Set time unit for specific datetime and timestamp
alphabetic_ts_36 = ats.base36.from_datetime(dt, time_unit=ats.TimeUnit.seconds)
alphabetic_ts_36 = ats.base36.from_timestamp(dt.timestamp(), time_unit=ats.TimeUnit.seconds)
# Examples of available time units
now36_ts = ats.base36.now(time_unit=ats.TimeUnit.seconds)
now36_ts = ats.base36.now(time_unit=ats.TimeUnit.deciseconds)
now36_ts = ats.base36.now(time_unit=ats.TimeUnit.centiseconds)
now36_ts = ats.base36.now(time_unit=ats.TimeUnit.milliseconds)
Possible Issue
There is a possible issue caused by bug in standard datetime module.
Metadata
Release files for alphabetic-timestamp 1.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| alphabetic_timestamp-1.1.5.tar.gz | 3.6 kB | Without provenance | Details |
Release files / alphabetic_timestamp-1.1.5.tar.gz
| Download URL | alphabetic_timestamp-1.1.5.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b61aae6e1157948d61157b4277fa7f9ba2437981f9c2e99d76589c101169356
|
|
BLAKE2b-256 checksum How to use checksums |
c3f0310cae5b425e237ce3c8420ee2cc68261fd24b5cd6a2f0238ba681c61f67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/2.7.15
|
Security for alphabetic-timestamp 1.1.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.