GeospatialPython/pyshp — pull request #18 by riggsd (2014-12-04 03:35:47+00:00)
Title: Seamlessly Read/Write `datetime.date` Objects

Pyshp's API is able to cast Python string/byte/unicode values, as well as numeric values. Its handling of Date fields is not so seamless. Users are expected to write exactly eight characters in YYYYMMDD format, then get handed a tuple of [year, month, day] ints when reading.

This patch allows writing values as `datetime.date` (or any subclass, eg. `datetime.datetime`). It also maintains backwards compatibility allowing the user to write a string value. It changes reading behavior, however, in that it now passes back a `datetime.date` object rather than a [year, month, day] int tuple.

A unit test is included; however I used the Python 2.1+ standard library's 'unittest' framework rather than grafting more doctests to the README file. Documentation has not been updated.