Date epoch problem
Posted: Fri Jul 18, 2008 4:45 pm
I searched for info in the documents, guide and here, but I can't see anything that points me right so please direct me to the proper place if necessary.
I have made a date entry checker function, to make it quicker than a calendar popup and less tedious than entering a whole date. (It will only be used for dd/mm/yyyy short format dates, although I could expand that if necessary, not that it will be.) If the user enters only a single value then it's assumed to be the day of the current month, current year. If the user puts two values separated by a slash, then it's assumed to be the day and month of the current year. If the user enters three values separated by slash then the user input is accepted as a date.
The following function works fine except for dates before 1970. If I want to check a date of birth entry field, for example, how do I set Rev to accept a year before the epoch start?
I have made a date entry checker function, to make it quicker than a calendar popup and less tedious than entering a whole date. (It will only be used for dd/mm/yyyy short format dates, although I could expand that if necessary, not that it will be.) If the user enters only a single value then it's assumed to be the day of the current month, current year. If the user puts two values separated by a slash, then it's assumed to be the day and month of the current year. If the user enters three values separated by slash then the user input is accepted as a date.
The following function works fine except for dates before 1970. If I want to check a date of birth entry field, for example, how do I set Rev to accept a year before the epoch start?
Code: Select all
function fnCheckValidDate pDate
local tDate
set the useSystemDate to true
put the date into tDate
convert tDate to short date
set the itemDelimiter to slash
if pDate is not empty then
if (0 < the number of items of pDate) and (the number of items of pDate < 4) then
if item 1 of pDate is not empty then put item 1 of pDate into item 1 of tDate
if item 2 of pDate is not empty then put item 2 of pDate into item 2 of tDate
if item 3 of pDate is not empty then put item 3 of pDate into item 3 of tDate
convert tDate to short date
if (tDate is not a date) or (the length of tDate is not 10) then
put empty into tDate
answer "The date has not been entered correctly"
end if
end if
end if
return tDate
end fnCheckValidDate