Skip to main content

sgtpyutils is a public library for use.

Project description

pypi version pypi download GitHub release GitHub All Releases GitHub last commit GitHub Workflow Status

WindowsLinuxUbuntuKaliFreeBSDDeepinDebianCent OS

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

Alt

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.12.tar.gz (47.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sgtpyutils-1.20.12-py3-none-any.whl (56.0 kB view details)

Uploaded Python 3

File details

Details for the file sgtpyutils-1.20.12.tar.gz.

File metadata

  • Download URL: sgtpyutils-1.20.12.tar.gz
  • Upload date:
  • Size: 47.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sgtpyutils-1.20.12.tar.gz
Algorithm Hash digest
SHA256 6c36e771868695b73705c0c832ac3177f1d613f694323fdb6884b2dd6440f1f1
MD5 756df68ab9fead41e3c3375604c8d7cc
BLAKE2b-256 c075e6aa5c783aa6ef4fdc908ebf2ee373214d32558f114d81ed9aa55d1a25c7

See more details on using hashes here.

File details

Details for the file sgtpyutils-1.20.12-py3-none-any.whl.

File metadata

  • Download URL: sgtpyutils-1.20.12-py3-none-any.whl
  • Upload date:
  • Size: 56.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sgtpyutils-1.20.12-py3-none-any.whl
Algorithm Hash digest
SHA256 757c8581c55e61bbae1ca4f538f3229ed5feb1473fca421be9e89f11fe027ee7
MD5 9dd819c810ce84ac6130341fc7d670b1
BLAKE2b-256 679c423e93ec30f99d94461f466c34cdcd0dffe4126daa4f71041795641c6690

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page