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

Uploaded Source

Built Distribution

sgtpyutils-1.20.8-py3-none-any.whl (51.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sgtpyutils-1.20.8.tar.gz
Algorithm Hash digest
SHA256 b3a4c0ae4f49793a95342224bf161982f32c84e10259724c28dac5407a1ccbfa
MD5 60253db3c4caebcb8748f3c6baff1806
BLAKE2b-256 c871584fd6e336fd5cb8d9a190e96af0718c9c6bd6c4d1534c1dd0faedab739e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for sgtpyutils-1.20.8-py3-none-any.whl
Algorithm Hash digest
SHA256 e944d11201850b063d803b186659fe78030556526e4f08a9db62ff4c01f3a089
MD5 f7717eff03d8517e077a81a5c5c99987
BLAKE2b-256 b6704ed743e23c4bbf8462d84614d0b73d579df701d869e0d7cbc9c4b8d38e72

See more details on using hashes here.

Supported by

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