URL: https://www.peterbe.com/plog/blogitem-040728-1/dateinputconverter

I'm envisioning a input form which asks initially for a date on a calendar. The next question is duration, or how long from that date. The input for this must be clever. So now I've put together a little script that adds numerically what someone enters in English.

The "problem" is what do you do when you add "1 month" when incrementing the month number is not enough? This program does like this: 2004-08-31 + 1 month = 2004-09-30.

Please have a try of my little program and let me know what you think

Comments

Post your own comment
djo

Changed something recently? Your page seems to be causing Sharpreader to start the debugger.

a) What are you trying to accomplish?
b) Rather than a simple text field, I'd use dropdowns (maybe leaving the year as text):

[08] [Apr] [2004]

c) What should happen when I add 1 month to Jan 31st? I think it's ambiguous enough that you're going to suprise some users whatever you do. I'd look for an alternative way to do whatever you're trying to do, one that makes the user feel more certain about what's about to happen. Maybe something graphical is better in this instance.

2004-01-31 + 1 Month = 2004-03-01
2004-07-31 + 4 Months = 2004-07-31

Hmm. That doesn't make sense to me.

d) 2004-07-32 + 4 Months = crash and burn. Yeah, I know, it's only a demo, but (b) above and some judicious javascript might help.

e) I have no idea what possible strings I can use. I'm guessing month, week, day, year, but I'm not sure. Can I use quarter? Decade? Suggest a drop-down with permitted fields, again.

Peter

a) The equivalent of the interval function in PostgreSQL. (see http://www.peterbe.com/Adding-a-year-in-PostgreSQL)

b) That's one way of doing it. This page is about another way.

c) From my limited research; in the English language if you say "one month from now" on the 31st of January you mean the last day of February, i.e. 28th or 29th.

d) 2004-07-32 does not exist.

e) I get your point. The hope is to make the user understand that he can write whatever he likes. The experiment here is to pretend to be smart and let users be able to express their input in plain english. Like voice commands for mobile phones do.

djo

Seems to be an IE Javascript problem:

Line: 16
Error: 'aeh' is undefined.

And... on the subject of usability:

I can type as much text as I want in this box, I can even preview successfully, but when I try to post I find I'm limited to 1000 chars.

In order of preference:

a) remove the 1000 char hard limit

b) Limit me to 1000 chars with Javascript, and warn me when I'm getting close (a percentage that updated onChange?)

c) Tell me my comment's too long on preview

d) Put a static "max 1000 characters" warning somewhere on the text entry box.

Peter

How did you manage to get an error about 'aeh'? That's my anti-spam-harvesting-script.

I've changed the limit to 8000 chars now. There is a limit to avoid DoS-like attacks.

Peter

Found the problem about "aeh". It was due to a bug in the program that optimizes the HTML before it's sent to the browser. Fixed now.

djo

No idea where the error came from, it just popped up in #Reader/IE. It went away pretty quickly, so it was either transient or you fixed it.

I disagree on (c) - quick straw-poll in the office here shows that "the last day of Jan + 1 month = the last day of Feb" (but with discussion and argument, which leads me to believe the tool is fundamentally ambiguous though).

On (b) of the above post, I was getting at the date-entry field, rather than the application as a whole (and I know this is pedantic for a demo). There are only two ways to define a date unambiguously, afaik. That's either 2004-08-07 or 08-JUL-2004. Anything else confuses Americans. The second is better IMO, because not everyone has come across weird ISO date formats.

Your email will never ever be published.

Related posts