/***********************************************************************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* Glenn Fowler24* AT&T Research25*26* time conversion support27*/2829#include <ast.h>30#include <tm.h>3132/*33* return timezone pointer given name and type34*35* if type==0 then all time zone types match36* otherwise type must be one of tm_info.zone[].type37*38* if end is non-null then it will point to the next39* unmatched char in name40*41* if dst!=0 then it will point to 0 for standard zones42* and the offset for daylight zones43*44* 0 returned for no match45*/4647Tm_zone_t*48tmzone(register const char* name, char** end, const char* type, int* dst)49{50register Tm_zone_t* zp;51register char* prev;52char* e;5354static Tm_zone_t fixed;55static char off[16];5657tmset(tm_info.zone);58if ((*name == '+' || *name == '-') && (fixed.west = tmgoff(name, &e, TM_LOCALZONE)) != TM_LOCALZONE && !*e)59{60strlcpy(fixed.standard = fixed.daylight = off, name, sizeof(off));61if (end)62*end = e;63if (dst)64*dst = 0;65return &fixed;66}67zp = tm_info.local;68prev = 0;69do70{71if (zp->type)72prev = zp->type;73if (!type || type == prev || !prev)74{75if (tmword(name, end, zp->standard, NiL, 0))76{77if (dst)78*dst = 0;79return zp;80}81if (zp->dst && zp->daylight && tmword(name, end, zp->daylight, NiL, 0))82{83if (dst)84*dst = zp->dst;85return zp;86}87}88if (zp == tm_info.local)89zp = tm_data.zone;90else91zp++;92} while (zp->standard);93return 0;94}959697