Skip to main content

guesstime

Project description

guesstime

尝试处理各种 时间字符串、datetieme、int、中文、24节气等等 返回给你 标准unix时间戳 int类型 或者 datetime类型 或者 arrow类型

使用了4个python纯离线时间处理库, 如有更多格式,请联系我加上处理

更多详细使用可见 example.py 文件

pip install guesstime
from guesstime import GuessTime
import datetime
import time
print(datetime.timedelta(seconds=time.time()).__str__())
print(GuessTime("Wed Mar 16 01:33:53 +0000 2016").offset(seconds=-60).to_datetime())
print((GuessTime(" 01:33:53").offset(seconds=-60, hours=6) - 6 - '2022-1-1'))
print(GuessTime("Wed Mar 16 01:33:53 +0000 2016").to_datetime())
print(GuessTime("Wed Mar 16 01:33:53 +0000 2016").to_datetime_with_change_timezone())
print(GuessTime("Wed Mar 16 01:33:53 +0000 2016").to_date_str_with_change_timezone())
print(GuessTime("Wed Mar 16 01:33:53 +0000 2016").to_date_str())
print(GuessTime("2021一月一hao").to_datetime())
print(GuessTime("2021一月2hao十八點").to_datetime())
print(GuessTime("2021.10 12 5:08pm CNT").to_datetime())
print(GuessTime("2021。10 12 5:08pm CNT").to_datetime())
print(GuessTime("2021/March.2 5:08pm CNT").to_datetime())
print(GuessTime("2021/10/12 5:08pm CNT").to_datetime())
print(GuessTime("(10/12 5:08pm CNT").to_datetime())
print(GuessTime("2021-10/12 5:08pm CNT").to_datetime())
print(GuessTime("2021-03-10T 17:08:00 +00:00").to_datetime())
print(GuessTime("March 10, 2021 5:08pm EST").to_arrow())
print(GuessTime(time.time()).to_datetime())
print(GuessTime(datetime.datetime.now()).to_timestamp())
print(GuessTime(datetime.date.today()).to_timestamp())
print(GuessTime("2022-03-11 18:14:27.913229 -08:00").to_datetime())
print(GuessTime("2022-03-11 18:14:27.913229-08:00").to_timestamp())
print(GuessTime(datetime.datetime.now()).to_timestamp_int())
print(GuessTime("2022-03-11 18:14:27.913229 -08:00").parse('这个月的第三个星期天').to_datetime())
print(GuessTime("2022-03-11 18:14:27.913229 -08:00").parse('今年的大寒').to_datetime())
print(GuessTime("2022-03-11 18:14:27.913229 -08:00").parse('今天中午十二点').to_datetime())
print(GuessTime("2022-03-11 18:14:27.913229 -08:00").parse('今天晚上8点').to_datetime())
print(GuessTime("2022-03-11 18:14:27.913229 -08:00").parse('今天晚上8点').to_arrow().weekday())
print(GuessTime("2022-03-11 18:14:27.913229 -08:00").parse('今天晚上8点').to_datetime().hour)
print(GuessTime("Wed 000 2016", raise_err=False).to_datetime(datetime.datetime.now()))
print(GuessTime("Wed 000 2016", raise_err=False).to_guess_filter_string())
19284 days, 15:26:27.809527
2016-03-16 01:32:53+00:00
291 days, 7:32:47
2016-03-16 01:33:53+00:00
2016-03-16 09:33:53+08:00
2016-03-16 09:33:53 CST
2016-03-16 09:33:53
2021-01-01 00:00:00+00:00
2021-01-02 18:00:00+00:00
2021-10-12 17:08:00+00:00
2021-10-12 17:08:00+00:00
2021-03-02 17:08:00+00:00
2021-10-12 17:08:00+00:00
2022-10-12 17:08:00+00:00
2021-10-12 17:08:00+00:00
2021-03-10 17:08:00+00:00
2021-03-10T17:08:00+00:00
2022-10-19 15:26:27.855769+00:00
1666221987.857278
1666137600.0
2022-03-12 02:14:27.913229+00:00
1647051267.913229
1666221987
2022-03-27 02:14:27+00:00
2023-01-20 02:14:27+00:00
2022-03-12 12:14:27+00:00
2022-03-12 20:14:27+00:00
5
20
2022-10-19 23:26:27.889916
Wed 000 2016

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

guesstime-1.1.4.tar.gz (329.5 kB view details)

Uploaded Source

Built Distribution

guesstime-1.1.4-py3-none-any.whl (338.7 kB view details)

Uploaded Python 3

File details

Details for the file guesstime-1.1.4.tar.gz.

File metadata

  • Download URL: guesstime-1.1.4.tar.gz
  • Upload date:
  • Size: 329.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for guesstime-1.1.4.tar.gz
Algorithm Hash digest
SHA256 9095977fb6e0ad85c659bfdef3c446ca5c78a35dbbdaaa00875915477c9ee803
MD5 b574dee5c722a3beb8df29333e5e5928
BLAKE2b-256 094b5807bebab7419baa30f78ea3a8a80dbff541538ac49b43b4f3fc2bc20f8e

See more details on using hashes here.

File details

Details for the file guesstime-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: guesstime-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 338.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for guesstime-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 894a9626a9300e1a93de4f8b962a5070935731b81cddc83760763e5d129c89ba
MD5 cbd286a2239a6bd690bb60df8ac03589
BLAKE2b-256 3568f8606e1c729c3e976cda6f8a5c863d66163673a613318b711599e737ce8d

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