Computer Science Canada Recording dates |
Author: | pmads [ Tue Dec 16, 2008 1:11 am ] |
Post subject: | Recording dates |
I need to have the user insert dates that will go into a data base and then be able to retrieve those dates and be able to sort them and display them by date. The problem I'm having is deciding how i am going to have the user input the dates to be able to sort them later. (there are a number of ways to say the same date i.e 12/16/08, Dec 16, 2008 etc. The only way i can think of is to display an error saying wrong format and tell the user the correct format if they didnt input it correctly, however i feel this too restricting to the user. Any suggestions on how I can go about doing this? |
Author: | DemonWasp [ Tue Dec 16, 2008 11:46 am ] |
Post subject: | RE:Recording dates |
Unfortunately, Turing is one of those languages that doesn't have a built-in way of handling dates. Although you could write one yourself, doing so is time-consuming and probably not the best use of your time. I would be insisting that users choose a specific format (I'm a fan of: 2008 Dec 16). Choose an unambiguous format, not 10/10/08, since that has different orderings in different countries. Once you've got a specified format like that, it should be fairly easy to check that the date exists (think carefully about Feb 29th). Alternately, you could allow multiple formats, and have some sort of country-detection scheme that lets you know whether you should expect mm/dd/yy or dd/mm/yy or... I really really don't recommend that. |
Author: | drij [ Tue Dec 16, 2008 1:04 pm ] |
Post subject: | Re: Recording dates |
Actually, Turing does have a built in module for working with times and dates. read up on the Time module in the Turing help files. Turing uses Unix time. Dates are internally represented as an integer counting the number of seconds since January 1, 1970. You might want to investigate how to use procedures like Time.SecStr and Time.PartsSec to convert from human readable dates to Unix time dates. Sorting your dates is easy if they're all just integers. ![]() |
Author: | andrew. [ Tue Dec 16, 2008 4:33 pm ] |
Post subject: | RE:Recording dates |
This is off-topic, but when you said Turing uses Unix time, it made me wonder even more why Holtsoft never released an up-to-date version of Turing for Linux or Mac OS. |