<p align="center">
<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fserfend%2Fsgtpyutils%2F"><img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fserfend%2Fsgtpyutils%2F&labelColor=%23697689&countColor=%23ff8a65&style=plastic&labelStyle=none" /></a>
<a href="https://pypi.python.org/pypi/sgtpyutils/"><img alt="pypi version" src="https://img.shields.io/pypi/v/sgtpyutils.svg" /></a>
<a href="https://pypistats.org/packages/sgtpyutils"><img alt="pypi download" src="https://img.shields.io/pypi/dm/sgtpyutils.svg" /></a>
<a href="https://github.com/serfend/sgtpyutils/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/serfend/sgtpyutils.svg?style=flat-square" /></a>
<a href="https://github.com/serfend/sgtpyutils/releases"><img alt="GitHub All Releases" src="https://img.shields.io/github/downloads/serfend/sgtpyutils/total.svg?style=flat-square&color=%2364ff82" /></a>
<a href="https://github.com/serfend/sgtpyutils/commits"><img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/serfend/sgtpyutils.svg?style=flat-square" /></a>
<a href="https://github.com/serfend/sgtpyutils/actions/workflows/pytest.yml"><img alt="GitHub Workflow Status" src="https://github.com/serfend/sgtpyutils/actions/workflows/pytest.yml/badge.svg" /></a>
</p>
![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white)![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black)![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white)![Kali](https://img.shields.io/badge/Kali-268BEE?style=for-the-badge&logo=kalilinux&logoColor=white)![FreeBSD](https://img.shields.io/badge/-FreeBSD-%23870000?style=for-the-badge&logo=freebsd&logoColor=white)![Deepin](https://img.shields.io/badge/Deepin-007CFF?style=for-the-badge&logo=deepin&logoColor=white)![Debian](https://img.shields.io/badge/Debian-D70A53?style=for-the-badge&logo=debian&logoColor=white)![Cent OS](https://img.shields.io/badge/cent%20os-002260?style=for-the-badge&logo=centos&logoColor=F0F0F0)
# What?
sgtpyutils is python module for common utils.
## Install
```shell
pip install sgtpyutils
```
## Usage
### 日志处理
```python
from sgtpyutils.logger import logger
logger.debug('调试')
logger.info('信息')
logger.warning('警告')
```
### 时间处理
```python
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](https://repobeats.axiom.co/api/embed/af8eefa7ce843f622f7dafbfe1879a36f872474d.svg "Repobeats analytics image")
Raw data
{
"_id": null,
"home_page": "https://github.com/serfend/sgtpyutils",
"name": "sgtpyutils",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.9",
"maintainer_email": null,
"keywords": "lib, utils",
"author": "serfend",
"author_email": "serfend@foxmail.com",
"download_url": "https://files.pythonhosted.org/packages/23/b7/7a4aa0c04d88bdb31cb76bbe9c2d1b46e9c532568289dfc1c81897801d91/sgtpyutils-1.20.5.tar.gz",
"platform": "any",
"description": "<p align=\"center\">\n <a href=\"https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fserfend%2Fsgtpyutils%2F\"><img src=\"https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fserfend%2Fsgtpyutils%2F&labelColor=%23697689&countColor=%23ff8a65&style=plastic&labelStyle=none\" /></a> \n <a href=\"https://pypi.python.org/pypi/sgtpyutils/\"><img alt=\"pypi version\" src=\"https://img.shields.io/pypi/v/sgtpyutils.svg\" /></a> \n <a href=\"https://pypistats.org/packages/sgtpyutils\"><img alt=\"pypi download\" src=\"https://img.shields.io/pypi/dm/sgtpyutils.svg\" /></a>\n <a href=\"https://github.com/serfend/sgtpyutils/releases\"><img alt=\"GitHub release\" src=\"https://img.shields.io/github/release/serfend/sgtpyutils.svg?style=flat-square\" /></a>\n <a href=\"https://github.com/serfend/sgtpyutils/releases\"><img alt=\"GitHub All Releases\" src=\"https://img.shields.io/github/downloads/serfend/sgtpyutils/total.svg?style=flat-square&color=%2364ff82\" /></a>\n <a href=\"https://github.com/serfend/sgtpyutils/commits\"><img alt=\"GitHub last commit\" src=\"https://img.shields.io/github/last-commit/serfend/sgtpyutils.svg?style=flat-square\" /></a>\n <a href=\"https://github.com/serfend/sgtpyutils/actions/workflows/pytest.yml\"><img alt=\"GitHub Workflow Status\" src=\"https://github.com/serfend/sgtpyutils/actions/workflows/pytest.yml/badge.svg\" /></a>\n</p>\n\n\n\n\n![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white)![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black)![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white)![Kali](https://img.shields.io/badge/Kali-268BEE?style=for-the-badge&logo=kalilinux&logoColor=white)![FreeBSD](https://img.shields.io/badge/-FreeBSD-%23870000?style=for-the-badge&logo=freebsd&logoColor=white)![Deepin](https://img.shields.io/badge/Deepin-007CFF?style=for-the-badge&logo=deepin&logoColor=white)![Debian](https://img.shields.io/badge/Debian-D70A53?style=for-the-badge&logo=debian&logoColor=white)![Cent OS](https://img.shields.io/badge/cent%20os-002260?style=for-the-badge&logo=centos&logoColor=F0F0F0)\n\n# What?\n\nsgtpyutils is python module for common utils.\n\n\n\n## Install\n\n```shell\npip install sgtpyutils\n```\n\n\n\n## Usage\n\n### \u65e5\u5fd7\u5904\u7406\n```python\nfrom sgtpyutils.logger import logger\nlogger.debug('\u8c03\u8bd5')\nlogger.info('\u4fe1\u606f')\nlogger.warning('\u8b66\u544a')\n```\n\n### \u65f6\u95f4\u5904\u7406\n```python\nfrom sgtpyutils.datetime import DateTime\n# \u5f53\u524d\u65f6\u95f4\nprint(DateTime()) # 2023-09-19 14:50:43.570560+08:00\n# \u6307\u5b9a\u65e5\u671f\nprint(DateTime('2023-09-19')) # 2023-09-19 00:00:00+08:00\n# \u6307\u5b9a\u65f6\u95f4\nprint(DateTime('2023-09-19 14:50:43')) # 2023-09-19 14:50:43+08:00\n# \u6307\u5b9a\u65f6\u95f4\u6233\nprint(DateTime(1695106243000)) # 2023-09-19 14:50:43+08:00\n# \u6307\u5b9a\u65f6\u95f4\u53ca\u65f6\u533a\nprint(DateTime('2023-09-19T14:50:43+07:00')) # 2023-09-19 14:50:43+07:00\n\n# \u8ba1\u7b97\u65f6\u95f4\u5dee\nprint((DateTime('2023-09-20') - '2023-09-19').total_seconds()) # 86400.0\nprint((DateTime('2023-09-20') - 60 * 1000)) # 2023-09-19 23:59:00+08:00\n\n# \u83b7\u53d6\u76f8\u5bf9\u65f6\u95f4\nprint(DateTime('2023-09-20').toRelativeTime('2023-09-20 14:23')) # 14\u5c0f\u65f6\u524d\nprint(DateTime('2023-09-20 10:00:00').toRelativeTime('2023-09-20 10:01:00')) # 1\u5206\u949f\u540e\nprint(DateTime('2023-01-20 10:00:00').toRelativeTime()) # xxx\u5e74\u524d\n```\n\n\n\n\n\n## Status\n\n![Alt](https://repobeats.axiom.co/api/embed/af8eefa7ce843f622f7dafbfe1879a36f872474d.svg \"Repobeats analytics image\")\n",
"bugtrack_url": null,
"license": "MIT Licence",
"summary": "sgtpyutils is a public library for use.",
"version": "1.20.5",
"project_urls": {
"Homepage": "https://github.com/serfend/sgtpyutils"
},
"split_keywords": [
"lib",
" utils"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6fffa273e7b122cd8422b473508796f2e020e404532834169262e70aa58d6ae4",
"md5": "f9066efe8be2e7e90a9f919f89e4c5cc",
"sha256": "906036cd34c1317877f09cbed5055ed7e7c334185c4397617c17ab2d9db5c4ec"
},
"downloads": -1,
"filename": "sgtpyutils-1.20.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f9066efe8be2e7e90a9f919f89e4c5cc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 51584,
"upload_time": "2024-10-16T11:56:14",
"upload_time_iso_8601": "2024-10-16T11:56:14.857029Z",
"url": "https://files.pythonhosted.org/packages/6f/ff/a273e7b122cd8422b473508796f2e020e404532834169262e70aa58d6ae4/sgtpyutils-1.20.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "23b77a4aa0c04d88bdb31cb76bbe9c2d1b46e9c532568289dfc1c81897801d91",
"md5": "aca759d594eb6e34c2c4cdc450ebbc28",
"sha256": "1b02b08ba1c132d15d0b1e464a663bf611272498cb949e27338eeb5f59532d59"
},
"downloads": -1,
"filename": "sgtpyutils-1.20.5.tar.gz",
"has_sig": false,
"md5_digest": "aca759d594eb6e34c2c4cdc450ebbc28",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 44622,
"upload_time": "2024-10-16T11:56:16",
"upload_time_iso_8601": "2024-10-16T11:56:16.371264Z",
"url": "https://files.pythonhosted.org/packages/23/b7/7a4aa0c04d88bdb31cb76bbe9c2d1b46e9c532568289dfc1c81897801d91/sgtpyutils-1.20.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-16 11:56:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "serfend",
"github_project": "sgtpyutils",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "sgtpyutils"
}