14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*8462SApril.Chin@Sun.COM * Copyright (c) 1985-2008 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 7*8462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * Glenn Fowler <gsf@research.att.com> * 184887Schin * David Korn <dgk@research.att.com> * 194887Schin * Phong Vo <kpv@research.att.com> * 204887Schin * * 214887Schin ***********************************************************************/ 224887Schin #pragma prototyped 234887Schin /* 244887Schin * strptime implementation 254887Schin */ 264887Schin 274887Schin #define strptime ______strptime 284887Schin 294887Schin #include <ast.h> 304887Schin #include <tm.h> 314887Schin 324887Schin #undef strptime 334887Schin 344887Schin #undef _def_map_ast 354887Schin #include <ast_map.h> 364887Schin 374887Schin #if _lib_strptime 384887Schin 394887Schin NoN(strptime) 404887Schin 414887Schin #else 424887Schin 434887Schin #if defined(__EXPORT__) 444887Schin #define extern __EXPORT__ 454887Schin #endif 464887Schin 474887Schin extern char* 484887Schin strptime(const char* s, const char* format, struct tm* ts) 494887Schin { 504887Schin char* e; 514887Schin char* f; 524887Schin time_t t; 534887Schin Tm_t tm; 544887Schin Tm_t* tn; 554887Schin 564887Schin tm.tm_sec = ts->tm_sec; 574887Schin tm.tm_min = ts->tm_min; 584887Schin tm.tm_hour = ts->tm_hour; 594887Schin tm.tm_mday = ts->tm_mday; 604887Schin tm.tm_mon = ts->tm_mon; 614887Schin tm.tm_year = ts->tm_year; 624887Schin tm.tm_wday = ts->tm_wday; 634887Schin tm.tm_yday = ts->tm_yday; 644887Schin tm.tm_isdst = ts->tm_isdst; 654887Schin t = tmtime(&tm, TM_LOCALZONE); 664887Schin t = tmscan(s, &e, format, &f, &t, 0); 674887Schin if (e == (char*)s || *f) 684887Schin return 0; 694887Schin tn = tmmake(&t); 704887Schin ts->tm_sec = tn->tm_sec; 714887Schin ts->tm_min = tn->tm_min; 724887Schin ts->tm_hour = tn->tm_hour; 734887Schin ts->tm_mday = tn->tm_mday; 744887Schin ts->tm_mon = tn->tm_mon; 754887Schin ts->tm_year = tn->tm_year; 764887Schin ts->tm_wday = tn->tm_wday; 774887Schin ts->tm_yday = tn->tm_yday; 784887Schin ts->tm_isdst = tn->tm_isdst; 794887Schin return e; 804887Schin } 814887Schin 824887Schin #endif 83