sgtpyutils is a public library for use.
Project description
What?
sgtpyutils is python module for common utils.
Install
pip install sgtpyutils
Usage
日志处理
from sgtpyutils.logger import logger
logger.debug('调试')
logger.info('信息')
logger.warning('警告')
时间处理
from sgtpyutils.datetime import DateTime
# 当前时间
print(DateTime()) # 2023-09-19 14:50:43.570560+08:00
# 指定日期
print(DateTime('2023-09-19')) # 2023-09-19 00:00:00+08:00
# 指定时间
print(DateTime('2023-09-19 14:50:43')) # 2023-09-19 14:50:43+08:00
# 指定时间戳
print(DateTime(1695106243000)) # 2023-09-19 14:50:43+08:00
# 指定时间及时区
print(DateTime('2023-09-19T14:50:43+07:00')) # 2023-09-19 14:50:43+07:00
# 计算时间差
print((DateTime('2023-09-20') - '2023-09-19').total_seconds()) # 86400.0
print((DateTime('2023-09-20') - 60 * 1000)) # 2023-09-19 23:59:00+08:00
# 获取相对时间
print(DateTime('2023-09-20').toRelativeTime('2023-09-20 14:23')) # 14小时前
print(DateTime('2023-09-20 10:00:00').toRelativeTime('2023-09-20 10:01:00')) # 1分钟后
print(DateTime('2023-01-20 10:00:00').toRelativeTime()) # xxx年前
Status
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sgtpyutils-1.20.5.tar.gz
(44.6 kB
view details)
Built Distribution
File details
Details for the file sgtpyutils-1.20.5.tar.gz
.
File metadata
- Download URL: sgtpyutils-1.20.5.tar.gz
- Upload date:
- Size: 44.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b02b08ba1c132d15d0b1e464a663bf611272498cb949e27338eeb5f59532d59 |
|
MD5 | aca759d594eb6e34c2c4cdc450ebbc28 |
|
BLAKE2b-256 | 23b77a4aa0c04d88bdb31cb76bbe9c2d1b46e9c532568289dfc1c81897801d91 |
File details
Details for the file sgtpyutils-1.20.5-py3-none-any.whl
.
File metadata
- Download URL: sgtpyutils-1.20.5-py3-none-any.whl
- Upload date:
- Size: 51.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 906036cd34c1317877f09cbed5055ed7e7c334185c4397617c17ab2d9db5c4ec |
|
MD5 | f9066efe8be2e7e90a9f919f89e4c5cc |
|
BLAKE2b-256 | 6fffa273e7b122cd8422b473508796f2e020e404532834169262e70aa58d6ae4 |