Skip to main content

Time Convert for Humans™

Project description

TimeConvert is a simple time convert script(library) for Python, built for human beings.

Installation

pip install TimeConvert

Usage

from TimeConvert import TimeConvert as tc

tc.utc_timestamp()

Variable

# Default Asia/Shanghai & %Y-%m-%d %H:%M:%S
from TimeConvert import TIME_ZONE, TIME_FORMAT

# Deassign TIME_ZONE & TIME_FORMAT
tc.__init__(timezone='Asia/Shanghai', format='%Y-%m-%d %H:%M:%S')

Method

# VALIDATE

def validate_string(string, format=TIME_FORMAT):

# REPLACE

def remove_microsecond(self, dt):

# DATETIME

def utc_datetime(ms=True):

def local_datetime(ms=True, timezone=None):

def is_utc_datetime(dt):

def is_local_datetime(dt, local_tz=None):

def to_utc_datetime(dt, timezone=TIME_ZONE):

def to_local_datetime(dt, timezone=TIME_ZONE):

def yesterday_utc_datetime(ms=True):

def tomorrow_utc_datetime(ms=True):

def yesterday_local_datetime(ms=True, timezone=None):

def tomorrow_local_datetime(ms=True, timezone=None):

def several_days_ago(dt=None, utc=True, days=0):

def several_days_coming(dt=None, utc=True, days=0):

def several_time_ago(dt=None, utc=True, days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0):

def several_time_coming(dt=None, utc=True, days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0):

# STRING

def utc_string(utc_dt=None, format=TIME_FORMAT):

def local_string(local_dt=None, format=TIME_FORMAT):

def datetime_to_string(dt, format=TIME_FORMAT):

# TIMESTAMP

def utc_timestamp(utc_dt=None, ms=False):

def local_timestamp(local_dt=None, ms=False):

def datetime_to_timestamp(dt, ms=False):

# STRING ==> DATETIME

def string_to_utc_datetime(string, format=TIME_FORMAT):

def string_to_local_datetime(string, format=TIME_FORMAT):

def utc_string_to_utc_datetime(self, utc_string, format=TIME_FORMAT):

# STRING ==> TIMESTAMP

def string_to_timestamp(string, format=TIME_FORMAT, ms=False):

def string_to_utc_timestamp(string, format=TIME_FORMAT, ms=False):

def string_to_local_timestamp(string, format=TIME_FORMAT, ms=False):

# TIME_DELTA

def timestamp_delta(stamp1, stamp2, interval=None):

def datetime_delta(dt1, dt2, interval=None):

def string_delta(string1, string2, interval=None, format=TIME_FORMAT, format1='', format2=''):

PS: interval(seconds) —— Time1 - Time2 >= interval ?

# TIME_COUNT_DOWN

def timestamp_countdown(stamp):

def datetime_countdown(dt):

def string_countdown(string, format=TIME_FORMAT):

# MIDNIGHT

def utc_datetime_midnight(self, utc_dt=None):

def utc_seconds_since_midnight(self, utc_dt=None):

def local_datetime_midnight(self, local_dt=None):

def local_seconds_since_midnight(self, local_dt=None):

def datetime_midnight(self, dt=None, utc=False):

def seconds_since_midnight(self, dt=None, utc=False):

# AWARE vs NAIVE

def is_aware(value):

def is_naive(value):

def make_aware(value, timezone=TIME_ZONE):

def make_naive(value, timezone=TIME_ZONE):

# OTHER

def total_seconds(td):  # timedelta

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

TimeConvert-1.3.11.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

TimeConvert-1.3.11-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file TimeConvert-1.3.11.tar.gz.

File metadata

File hashes

Hashes for TimeConvert-1.3.11.tar.gz
Algorithm Hash digest
SHA256 b5e56ea797b134f51029238e17d2b57fbfd81480dc4288f7b941ed60e6452f41
MD5 afb11e157bb1bf222cc01a9062f26b6a
BLAKE2b-256 ad7282c98a3a9efaf2c4adbf5c3249a946c6a3602e4d1e7d5764d831d4f8f66d

See more details on using hashes here.

File details

Details for the file TimeConvert-1.3.11-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for TimeConvert-1.3.11-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ead14c429c588978e1c60211f99cdb3b7b3d6b5d7abf9fe586c2605df7a64ee5
MD5 e67027c35603b1cfbe6484aa65f720fc
BLAKE2b-256 a8a74a9db8223bb6d1ce6b0ddeb203e5cdde569707265bdc9b482c26911c7181

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