I did something similiar to caluclate the age of someone, the string was in YYYYMMDD,
might help you out.
/*****************************************************************************
*
* Function : CalculateAge
*
* Created : 5/1/01
* Creator : Philip Streck
* Description : takes a string in the format of YYYYMMDD and calculates the
* age of something compared to the current date.
*
****************************************************************************/
static UInt32
CalculuateAge ( Char * dob )
{
UInt32 age, i;
Char birthyear[4];
Char * month;
Char * day;
DateTimeType today;
TimSecondsToDateTime ( TimGetSeconds (), &today );
age = today.year - ( StrAToI ( StrNCopy ( birthyear, dob, 4 ) ) );
for ( i=0; i<=3; i++ )
dob++;
month = dob-2;
for ( i=0; i<=1; i++ )
dob++;
day = dob;
if ( today.month < StrAToI ( month ) )
age--;
else if ( today.month == StrAToI ( month ) )
if ( today.day < StrAToI ( day ) )
age--;
return age;
}
Philip Streck
Akron General Medical Center
Information Systems
>>> "Mark Douglas" <[EMAIL PROTECTED]> 05/03/01 04:24PM >>>
Has anyone taken an ASCII date in a format like mm/dd/yy and stuffed it into
a DateType. I am curious how you populate the DateType structure. The
declaration of the structure looks foreign to me. It looks like it should be
6 Bytes but is really only 2.
I see that there is a DateToAscii function, but no AsciiToDate.
Mark Douglas
typedef struct{
UInt16 year :7; //years since 1904 (Mac format)
UInt16 month:4;
UInt16 day :5;
}DateType;
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/