Skip to main content

Create dates from natural language expressions

Project description

stringtime

A grammar for deriving Date objects from phrases.

api currently looks something like this...

from stringtime import Date
somedate = Date.from_phrase('an hour from now')

but is early days so will probably eventually parse via the Date constructor and on fail pass along to the regular dateutil parser.

Installation

python3 -m pip install stringtime

Usage and API

Here's a list of example phrases that can be used...

"an hour from now"
"1 hour from now"
"1 hour ago"
"Today"
"Yesterday"
"Tomorrow"
"Tuesday"
"On Wednesday"
"This Friday at 1"
"Last Wednesday at 5"

to see what else check the unit tests.

... more to come.

CLI

There's several commands you can pass to sharpshooter on the command line.

stringtime -p 2 days frome now

Tests

make test

License

Do what you want with this code.

Uses David Beazley's PLY parser.

Disclaimer

Might be buggy... only just made it yesterday.

Probs ignore this til at least version 0.3.

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

stringtime-0.0.1.tar.gz (13.4 kB view hashes)

Uploaded Source

Built Distribution

stringtime-0.0.1-py3-none-any.whl (13.3 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