Inspired and copied from http://simon.incutio.com/code/js/date-parser/ and http://javascript.internet.com/calendars/fuushikaden-pop-up-calendar.html

This I think is a very neat way of inputting dates on a web form. The server side code must thus be able to parse both 13 december 2003 and 13/12/2003 but that shouldn't be too hard with the DateTime module.

Look at the demo

If you have a browser with which this doesn't work let me know by posting a comment here.

UPDATE this demo had a little bug in the output that I have now fixed.

Comments

Post your own comment
Sönke

Hi Peter,
what about i18n? I'm from germany and need to fill in something like '13 März 2004'.
Is this possible?

Greets, Sönke

Peter

Not sure. You can translate the strings in the javascript for the dateparse.
For the popup calendar I guess that's the same too.
I.e. search for "Mars" and replace it with "März".

Anonymous

very nice. I notice that If I put my birthdate as 7/8/1969 (US month/date) it interprets it as date/month (7th of august instead of 8th of july) but I like it! Mind if I download the javascript and start using it?

Jim

very nice. I notice that If I put my birthdate as 7/8/1969 (US month/date) it interprets it as date/month (7th of august instead of 8th of july) but I like it! Mind if I download the javascript and start using it?

Peter

That's because you americans are wrong! No, actually I hacked the original script to do the british style before the american style. See the dateparse.js source and look for comments with 'Peter' in them.

Andreas

It's not a matter of who is wrong or not. Wrong attitude!

Sascha Welter

Peter: That javascript seems to be a bit dated, it has bugs that show up once you set a DOCTYPE on the html, something like described here: http://javascript.about.com/library/bliebug.htm
but it's not using document.documentElement or document.body (as mentioned in that article). It works without a DOCTYPE (as in your demo) or with a DOCTYPE for HTML 3.2, but it sets the position of the calendar wrong with any more modern DOCTYPE string in IE, Safari, and Firefox.

Since I'm not a JavaScript dude, I've not attempted to fix things so far.

Hey, and what's up? You're not on #zope any more?

Sascha Welter

Found an updated version at:
http://www.thalys.com/js/calendar.js?lg=en&country=fr
(Which works fine even with newer browsers using proper DOM.) Calling the popup seems to have a different method signature, and I haven't figured out too much yet, but something like onclick="popUpCalendar(this, this, 'dd-mm-yy','17-04-2001','01-01-2038') seems to work.

Your email will never ever be published.

Previous:
My breakfast October 17, 2003 This site
Next:
Systembolaget under pressure October 21, 2003
Related by category:
'Cache-Control' or Expires September 16, 2005 Zope
To all Zope developers: Does this sound familiar? March 8, 2011 Zope
IssueTrackerProduct now officially abandoned March 30, 2012 Zope
Sending HTML emails in Zope October 26, 2006 Zope
Related by keyword:
Fastest Python datetime parser May 2, 2018 Python
Django forms and making datetime inputs localized December 4, 2015 Python, Django
Date formatting in python or in PostgreSQL July 20, 2004 Python
Date formatting in Python or in PostgreSQL (part II) April 19, 2006 Python