/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped22/*23* getdate implementation24*/2526#define getdate ______getdate2728#include <ast.h>29#include <tm.h>3031#undef getdate3233#undef _def_map_ast34#include <ast_map.h>3536#undef _lib_getdate /* we can pass X/Open */3738#if _lib_getdate3940NoN(getdate)4142#else4344#ifndef getdate_err45__DEFINE__(int, getdate_err, 0);46#endif4748#if defined(__EXPORT__)49#define extern __EXPORT__50#endif5152extern struct tm*53getdate(const char* s)54{55char* e;56char* f;57time_t t;58Tm_t* tm;5960static struct tm ts;6162t = tmscan(s, &e, NiL, &f, NiL, TM_PEDANTIC);63if (*e || *f)64{65/* of course we all know what 7 means */66getdate_err = 7;67return 0;68}69tm = tmmake(&t);70ts.tm_sec = tm->tm_sec;71ts.tm_min = tm->tm_min;72ts.tm_hour = tm->tm_hour;73ts.tm_mday = tm->tm_mday;74ts.tm_mon = tm->tm_mon;75ts.tm_year = tm->tm_year;76ts.tm_wday = tm->tm_wday;77ts.tm_yday = tm->tm_yday;78ts.tm_isdst = tm->tm_isdst;79return &ts;80}8182#endif838485