A lightweight datetime library support year from -100000 to 100000.
Project description
alldatetime
A lightweight datetime library support year from -100000 to 100000
Install
pip install alldatetime
Usage
alldate
Initiate an instance
Initiate an alldate instance by constructor:
from alldatetime.alldatetime import alldate
ad = alldate(-1566, 1, 1)
print(ad.timestamp) # -111553804800
Or initiate an alldate instance from epoch timestamp:
from alldatetime.alldatetime import alldate
ad = alldate.fromtimestamp(-111553804800)
print(ad) # -1566-01-01
Formating
from alldatetime.alldatetime import alldate
alldate(-5000, 1, 8).strftime("%Y-%m-%d") # "5000-01-08 BC"
alltime
Initiate an instance
Initiate an alltime instance by constructor:
from alldatetime.alldatetime import alltime
at = alltime(5, 10, 0, 0)
Formating
from alldatetime.alldatetime import alltime
alltime(1, 15, 30, 1541).strftime("%H:%M:%S.%f") # "01:15:30.001541"
alldatetime
Initiate an instance
Initiate an alldatetime instance by constructor:
from alldatetime.alldatetime import alldatetime
adt = alldatetime(-1566, 1, 1, 12, 0, 0, 0)
print(adt.timestamp) # -111553761600
Or initiate an alldate instance from epoch timestamp:
from alldatetime.alldatetime import alldatetime
adt = alldatetime.fromtimestamp(-111553761600)
print(adt) # -1566-01-01 12:00:00
Formating
from alldatetime.alldatetime import alldatetime
alldatetime.strptime("5000-01-08 08:30:15 BC", "%Y-%m-%d %H:%M:%S") # alldatetime(-5000, 1, 8, 8, 30, 15)
alldatetime.strptime("5000/01/08 08:30:15 BC", "%Y/%m/%d %H:%M:%S") # alldatetime(-5000, 1, 8, 8, 30, 15)
alldatetime.strptime("2000-01-08 08:30:15 AD", "%Y-%m-%d %H:%M:%S") # alldatetime(2000, 1, 8, 8, 30, 15)
alldatetime.strptime("2000-01-08 08:30:15", "%Y-%m-%d %H:%M:%S") # alldatetime(2000, 1, 8, 8, 30, 15)
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
alldatetime-0.0.2.tar.gz
(7.5 kB
view hashes)
Built Distribution
Close
Hashes for alldatetime-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc9be0851b16e6d52eed1e8a40d0197354fac1b35097a70419cf8b05de1f819b |
|
MD5 | eeee3f7def2f254bbd7c5572ba8a6ae5 |
|
BLAKE2b-256 | c40473e8376052b3d6fa76c5e4a36a5fbfc2ba59ee661381ca4f345b1e720e50 |