@ Interface stamptransformmer + (unsigned long) getstamp :( nsstring *) input; @ end @ implementation stamptransformmer + (unsigned long) getstamp :( nsstring *) input {const char * timestr; unsigned long ret; unsigned long lyearcount; unsigned long year, month, day, hour, Min, SEC; timestr = [input utf8string]; sscanf (timestr, "% u-% u: % u", & year, & month, & day, & hour, & min, & Sec ); unsigned long daysum [] = {0, 31, 59, 90,120,151,181,212,243,273,304,334}; lyearcount = (year-1)/4-(year-1)/100 + (year-1)/400) -(1969/4-1969/100 + 1969/400); ret = (year-1970) * 365*24*3600 + lyearcount * 24*3600; RET + = daysum [month-1] * 24*3600; If (month> 2 & (Year % 4 = 0 & year % 100! = 0) | year % 400 = 0) RET + = 24*3600; RET + = (day-1) * 24*3600 + hour * 3600 + min * 60 + sec; return ret;} @ endint main () {NSAID utoreleasepool * pool; pool = [[NSAID utoreleasepool alloc] init]; nslog (@ "% u", [stamptransformmer getstamp: @ "17:40:50"]); [pool release]; return 0 ;}