Skip to main content

A useful time transform util, transforms between string, timestamp and datetime format

Project description

TimeKong

time kong

Time converter between timestamp, string and datetime.

Installation

You can install time-kong simply with pip:

pip install time-kong

Usages

TimeKong

Convert time between timestamp, string and datetime:

from datetime import datetime

from time_kong import TimeKong

ts = 1558883766.864879
TimeKong.timestamp2string(ts, formatter="%Y-%m-%d %H:%M:%S.%f")
# '2019-05-26 23:16:06.864879'
TimeKong.timestamp2datetime(ts)
# datetime.datetime(2019, 5, 26, 23, 16, 6, 864879)

ds = '2019-05-26 23:16:06.864879'
TimeKong.string2timestamp(ds, formatter="%Y-%m-%d %H:%M:%S.%f")
# 1558883766.864879
TimeKong.string2datetime(ds, formatter="%Y-%m-%d %H:%M:%S.%f")
# datetime.datetime(2019, 5, 26, 23, 16, 6, 864879)

dt = datetime(year=2019, month=5, day=26, hour=22, minute=42, second=26, microsecond=864879)
TimeKong.datetime2timestamp(dt)
# 1558881746.864879
TimeKong.datetime2string(dt, formatter="%Y-%m-%d %H:%M:%S.%f")
# '2019-05-26 22:42:26.864879'

Constants included:

  1. TimeKong.NANOSECOND
  2. TimeKong.MICROSECOND
  3. TimeKong.MILLISECOND
  4. TimeKong.SECOND
  5. TimeKong.MINUTE
  6. TimeKong.HOUR
  7. TimeKong.DAY
  8. TimeKong.WEEK
  9. TimeKong.MONTH
  10. TimeKong.YEAR

Author

time-kong is developed and maintained by fanwei.zeng (stayblank@gmail.com). It can be found here:

https://github.com/PurpleSun/time_kong

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

time-kong-0.0.3.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file time-kong-0.0.3.tar.gz.

File metadata

  • Download URL: time-kong-0.0.3.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.10

File hashes

Hashes for time-kong-0.0.3.tar.gz
Algorithm Hash digest
SHA256 49bc435ab01a6a941e3ab0e6af74c1319f90036ec16c1f3eb588d55ecaa92009
MD5 78aabfcb29f700e71a7b83eb4833a89a
BLAKE2b-256 30c45f2d2ec6b1757afb4cbb00ec110718c0c4fc0851a636dbff3ef3e0e2e9f4

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