• Stars
    star
    694
  • Rank 64,724 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 12 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Parse human-readable date/time strings

parsedatetime

Parse human-readable date/time strings.

PyPI Version Build Status Code Coverage

Parsedatetime now targets Python 3 and is currently tested with Python 3.9

Use https://github.com/bear/parsedatetime/releases/tag/v2.6 if you need Python 2.7 compatibility.

Installing

You can install parsedatetime using

pip install parsedatetime

Development environment

Development is done using a pipenv virtural environment

make env

Note: black is still listed as a beta library, and as such, must be installed with the --pre flag

Running Tests

From the source directory

make test

To run tests on several Python versions that are installed in the pipenv virtual environment

$ make tox
[... tox creates a virtualenv for every python version and runs tests inside of each]
py39: commands succeeded

The tests depend on PyICU being installed using the pyicu-binary package which removes the source build step. PyICU depends on icu4c which on macOS requires homebrew

brew install icu4c

Using parsedatetime

Detailed examples can be found in the examples directory.

as a time tuple

import parsedatetime
    
cal = parsedatetime.Calendar()
cal.parse("tomorrow")

as a Python datetime object

from datetime import datetime

time_struct, parse_status = cal.parse("tomorrow")
datetime(*time_struct[:6])

with timezone support using pytz

import parsedatetime
from pytz import timezone

cal = parsedatetime.Calendar()
datetime_obj, _ = cal.parseDT(datetimeString="tomorrow", tzinfo=timezone("US/Pacific"))

Documentation

The generated documentation is included by default in the docs directory and can also be viewed online at https://bear.im/code/parsedatetime/docs/index.html

The documentation is generated with

make docs

Notes

The Calendar class has a member property named ptc which is created during the class init method to be an instance of parsedatetime_consts.CalendarConstants().

History

The code in parsedatetime has been implemented over the years in many different languages (C, Clipper, Delphi) as part of different custom/proprietary systems I've worked on. Sadly the previous code is not "open" in any sense of that word.

When I went to work for Open Source Applications Foundation and realized that the Chandler project could benefit from my experience with parsing of date/time text I decided to start from scratch and implement the code using Python and make it truly open.

After working on the initial concept and creating something that could be shown to the Chandler folks, the code has now evolved to its current state with the help of the Chandler folks, most especially Darshana.

More Repositories

1

python-twitter

A Python wrapper around the Twitter API.
Python
3,413
star
2

s3scan

scan s3 buckets for security issues
Python
83
star
3

ronkyuu

่ซ–ๅŠ ronkyuu - mention, reference to, touching upon
HTML
42
star
4

kaku-deprecated

ๆ›ธใ- to write
Makefile
25
star
5

python-indieweb

Example Flask App to test Indieweb features
Python
19
star
6

indie-stats

Indieweb site crawler and MF2 data collection tool
Python
11
star
7

bearlib-deprecated

A Python module of items that I use often in projects and got tired of copying from project to project
Python
10
star
8

ninka-deprecated

่ชๅฏ - ninka - permission, license, to approve, permit
Python
9
star
9

tenki-deprecated

ๅคฉๆฐ— weather
Python
9
star
10

kenkou-deprecated

ๅฅๅบท - health -- small python tool to check that an http resource is alive
Python
6
star
11

iptable-tools

bash script to ease iptable rule handling
Shell
4
star
12

babble-deprecated

yes, another python bot - this one is geared to new coders
Python
4
star
13

relengbot

RelEng Bot
Python
3
star
14

palala

taming the river of news
Python
3
star
15

github-archive

Create a tarball of the cloned repo and all issues
Python
2
star
16

chef-cookbook-inspircd

Ruby
2
star
17

hakkan-deprecated

็™บๅˆŠ hakkan - to publish
Makefile
2
star
18

PythonFlaskTesting

Resources and Notes from my Python Testing talk
2
star
19

kagami-deprecated

tool to ship logstash events to a remote logstash server using zeromq
Python
2
star
20

kosu-deprecated

ใ“ใ™ - to filter, to strain
Clojure
2
star
21

dainin-deprecated

ไปฃไบบ dainin -- a proxy, substitute, deputy or agent - a tool to manage events and actions on my behalf
Python
2
star
22

chiru_js-deprecated

scatter tasks/jobs to workers
JavaScript
1
star
23

indiewebnews-deprecated

IndieWeb News aggregator
Python
1
star
24

danron-deprecated

่ซ‡่ซ– danron - discussion
Makefile
1
star
25

rsinfo

Rackspace Server Info
Python
1
star
26

OpsNotes-deprecated

Collection of notes and links relating to Ops
Python
1
star
27

bear-deprecated

tools, notes and .dot files
Shell
1
star
28

kyaku-deprecated

Automated tool to manage social media events using good old mailing list tech
Python
1
star