Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pyttles

Name: Anonymous 2008-06-12 11:40

I want to be able to parse a date and time string for the locale set in the user's system using forced indentation. I also want it to be flexible so it first tries to parse a full date and time, if that fails it tries full date with hours and minutes and lastly just a date in case the user doesn't want to specify the time or doesn't want to bother with seconds.
Neither time.strptime nor datetime.datetime.strptime seems to care about locale settings on my system (on the other hand, strftime for both modules does). What is this bullshit? Should I just force the users to wrap their heads around ISO 8601?

Name: Anonymous 2008-06-12 20:18

>>1
Don't. Don't make your program try to parse several kinds of dates, that's just going to cause problems.

I hate having to guess if applications want dd/mm/yy or mm/dd/yy. I don't even know what my locale says about dates right now. Don't trust the user's locale for anything other than timezones; odds are that it's not going to be 100% accurate and it's just going to make the user confused ("What kind of date do you want, again?").

This is one of the few cases where it's better to force the user to adapt instead of trying to make the program "user friendly."

Just pick one date format and stick with it. Use a reminder next to the field (something like yyyy-mm-dd) or use dropdowns/calendars if you must.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List