Hi > How do i convert ascii to date? > have a function?
I've written a inverse function to DateToAscii() for my project => AsciiToData() hope this helps see also: http://cvs.sourceforge.net/viewcvs.py/aquapalm/divelog/divelog.c?rev=1.82&view=auto by(e) Stephan /** * This routine reads the date from an ASCII string * * @param day - out: day * @param month - out: month * @param year - out: year * @param datetype - date format * @param str - date as string * * @return string read successfully * * @note <b> Revision History: </b> \n * * ***********************************************************************/ Boolean AsciiToDate(Int16 *month, Int16 *day, Int16 *year, DateFormatType datetype, char *str) { char *tmpstr,*datestr,sep[2],datetmp[15]; Boolean ret=false; *day=1; *month=1; *year=2000; if (!str) return false; StrNCopy(datetmp,str,14); datestr=datetmp; sep[0]=0x00; sep[1]=0x00; switch (datetype) { case dfDMYWithDots: case dfDMYWithDashes: case dfDMYWithSlashes: if (datetype==dfDMYWithDots) sep[0]='.'; if (datetype==dfDMYWithDashes) sep[0]='-'; if (datetype==dfDMYWithSlashes) sep[0]='/'; tmpstr=StrStr(datestr,sep); if (!tmpstr) return false; *tmpstr=0x00; *day=StrAToI(datestr); datestr=tmpstr+1; tmpstr=StrStr(datestr,sep); if (!tmpstr) return false; *tmpstr=0x00; *month=StrAToI(datestr); datestr=tmpstr+1; *year=StrAToI(datestr); ret=true; break; case dfMDYWithSlashes: sep[0]='/'; tmpstr=StrStr(datestr,sep); if (!tmpstr) return false; *tmpstr=0x00; *month=StrAToI(datestr); datestr=tmpstr+1; tmpstr=StrStr(datestr,sep); if (!tmpstr) return false; *tmpstr=0x00; *day=StrAToI(datestr); datestr=tmpstr+1; *year=StrAToI(datestr); ret=true; break; case dfYMDWithSlashes: case dfYMDWithDots: case dfYMDWithDashes: if (datetype==dfYMDWithDots) sep[0]='.'; if (datetype==dfYMDWithDashes) sep[0]='-'; if (datetype==dfYMDWithSlashes) sep[0]='/'; tmpstr=StrStr(datestr,sep); if (!tmpstr) return false; *tmpstr=0x00; *year=StrAToI(datestr); datestr=tmpstr+1; tmpstr=StrStr(datestr,sep); if (!tmpstr) return false; *tmpstr=0x00; *month=StrAToI(datestr); datestr=tmpstr+1; *day=StrAToI(datestr); ret=true; break; default: break; } // Y2K if (*year<100) *year+=1900; if (*year<1930) *year+=100; return ret; } -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
