Skip to main content

guesstime

Project description

guesstime

尝试处理各种时间字符串返回给你 标准unix时间戳 int类型 或者 datetime类型

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

更多详细可见 example.py 文件

from guesstime import GuessTime                               

print(GuessTime(time.time()).to_datetime())

print(GuessTime(datetime.datetime.now()).to_timestamp())

print(GuessTime(datetime.date.today()).to_timestamp())

print(GuessTime("March 10, 2021 5:08pm EST").to_datetime())

print(GuessTime("2021 10.2 5:08pm CNT").to_datetime())

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())

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())
2022-03-11 10:54:04.418433+00:00
1647024844.423416
1646956800.0
2021-03-10 17:08:00+00:00
2021-10-11 17:08:00+00:00
2022-03-12 02:14:27.913229+00:00
1647051267.913229
1647024844.453098
2022-03-20 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

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.0.0.tar.gz (31.1 kB view hashes)

Uploaded Source

Built Distribution

guesstime-1.0.0-py3-none-any.whl (30.4 kB view hashes)

Uploaded Python 3

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