14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1985-2010 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 78462SApril.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 * getdate implementation 254887Schin */ 264887Schin 274887Schin #define getdate ______getdate 284887Schin 294887Schin #include <ast.h> 304887Schin #include <tm.h> 314887Schin 324887Schin #undef getdate 334887Schin 344887Schin #undef _def_map_ast 354887Schin #include <ast_map.h> 364887Schin 374887Schin #undef _lib_getdate /* we can pass X/Open */ 384887Schin 394887Schin #if _lib_getdate 404887Schin 414887Schin NoN(getdate) 424887Schin 434887Schin #else 444887Schin 454887Schin #ifndef getdate_err 464887Schin __DEFINE__(int, getdate_err, 0); 474887Schin #endif 484887Schin 494887Schin #if defined(__EXPORT__) 504887Schin #define extern __EXPORT__ 514887Schin #endif 524887Schin 534887Schin extern struct tm* 544887Schin getdate(const char* s) 554887Schin { 564887Schin char* e; 574887Schin char* f; 584887Schin time_t t; 594887Schin Tm_t* tm; 604887Schin 614887Schin static struct tm ts; 624887Schin 634887Schin t = tmscan(s, &e, NiL, &f, NiL, TM_PEDANTIC); 644887Schin if (*e || *f) 654887Schin { 664887Schin /* of course we all know what 7 means */ 674887Schin getdate_err = 7; 684887Schin return 0; 694887Schin } 704887Schin tm = tmmake(&t); 714887Schin ts.tm_sec = tm->tm_sec; 724887Schin ts.tm_min = tm->tm_min; 734887Schin ts.tm_hour = tm->tm_hour; 744887Schin ts.tm_mday = tm->tm_mday; 754887Schin ts.tm_mon = tm->tm_mon; 764887Schin ts.tm_year = tm->tm_year; 774887Schin ts.tm_wday = tm->tm_wday; 784887Schin ts.tm_yday = tm->tm_yday; 794887Schin ts.tm_isdst = tm->tm_isdst; 804887Schin return &ts; 814887Schin } 824887Schin 834887Schin #endif 84