Giter Site home page Giter Site logo

jzmiller1 / django-date-extensions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dracos/django-date-extensions

0.0 2.0 0.0 91 KB

Extensions to DateField to handle both approximate dates (e.g. "March 1963") and default year dates (e.g. assume "24th June" is this year)

License: Other

Python 94.45% HTML 5.55%

django-date-extensions's Introduction

django-date-extensions
by Matthew Somerville

This code adds a few small extensions to Django's DateField, to handle both
approximate dates (e.g. "March 1963") and default year dates (e.g. assume
"24th June" is the most recent such).

example contains a hopefully self-contained Django project that simply shows
off a form with these methods of entry.

Approximate dates
=================

A new object, ApproximateDate, is used to represent dates that might not have a
month or a day. ApproximateDateField is the model field used to represent these
objects in a Model, and ApproximateDateFormField is the field used in a Django
form. Everything should work seamlessly simply by specifying a model field as
ApproximateDateField rather than DateField.

Default year dates
==================

PrettyDateField is a form field to be used on DateField model fields. It takes
one argument, future, which is a nullable boolean. If True, a date input that
is missing a year will be taken to be the next possible occurrence of that date
- e.g. on 24th November 2009, entering 24th December will be taken to be
2009-12-24, whilst entering 3rd March will be taken to be 2010-03-03. If future
is False, the reverse occurs, with year-less dates being assumed to be the
closest occurrence of that date in the past.

If future is not set, then PrettyDateField acts the same as a DateField, only
allows suffixes on ordinals, and assumes D/M/Y rather than M/D/Y. 

Todo
====

Improve date parsing to take more inputs like my traintimes.org.uk PHP, such as
"next Friday".


Any queries or comments, do get in touch. Something's probably broken, as I tried
to tidy up the code a little for public release :)

Matthew Somerville.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.