mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Backport changes to AST time library from ksh 93v- beta
This incorporates the last changes in the tm library before AT&T laid off the AST developers. It contains mostly time zone and locale related changes/fixes. I was hoping these would fix #52 (locale-based 'printf %T' output is broken), but no such luck. This is probably good to have anyway.
This commit is contained in:
parent
0a10e76ccc
commit
9f43f8d10b
6 changed files with 151 additions and 44 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/***********************************************************************
|
||||
* *
|
||||
* This software is part of the ast package *
|
||||
* Copyright (c) 1985-2011 AT&T Intellectual Property *
|
||||
* Copyright (c) 1985-2012 AT&T Intellectual Property *
|
||||
* and is licensed under the *
|
||||
* Eclipse Public License, Version 1.0 *
|
||||
* by AT&T Intellectual Property *
|
||||
|
|
@ -14,9 +14,9 @@
|
|||
* AT&T Research *
|
||||
* Florham Park NJ *
|
||||
* *
|
||||
* Glenn Fowler <gsf@research.att.com> *
|
||||
* David Korn <dgk@research.att.com> *
|
||||
* Phong Vo <kpv@research.att.com> *
|
||||
* Glenn Fowler <glenn.s.fowler@gmail.com> *
|
||||
* David Korn <dgkorn@gmail.com> *
|
||||
* Phong Vo <phongvo@gmail.com> *
|
||||
* *
|
||||
***********************************************************************/
|
||||
#pragma prototyped
|
||||
|
|
@ -111,6 +111,7 @@ tmxfmt(char* buf, size_t len, const char* format, Time_t t)
|
|||
int prec;
|
||||
int parts;
|
||||
char* arg;
|
||||
char* e;
|
||||
char* f;
|
||||
const char* oformat;
|
||||
Tm_t* tm;
|
||||
|
|
@ -471,12 +472,26 @@ tmxfmt(char* buf, size_t len, const char* format, Time_t t)
|
|||
p = tm_info.format[TM_RECENT];
|
||||
goto push;
|
||||
case 'z': /* time zone nation code */
|
||||
if (!(flags & TM_UTC))
|
||||
if (arg)
|
||||
{
|
||||
if ((zp = tmzone(arg, &e, NiL, NiL)) && !*e)
|
||||
{
|
||||
tm->tm_zone = zp;
|
||||
flags &= ~TM_UTC;
|
||||
}
|
||||
}
|
||||
else if (!(flags & TM_UTC))
|
||||
{
|
||||
if ((zp = tm->tm_zone) != tm_info.local)
|
||||
{
|
||||
for (; zp >= tm_data.zone; zp--)
|
||||
{
|
||||
if (p = zp->type)
|
||||
goto string;
|
||||
if (zp->standard == zp->daylight)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (p = zp->type)
|
||||
goto string;
|
||||
}
|
||||
|
|
@ -597,10 +612,14 @@ tmxfmt(char* buf, size_t len, const char* format, Time_t t)
|
|||
if (arg)
|
||||
{
|
||||
if ((zp = tmzone(arg, &f, 0, 0)) && !*f && tm->tm_zone != zp)
|
||||
{
|
||||
tm = tmxtm(tm, tmxtime(tm, tm->tm_zone->west + (tm->tm_isdst ? tm->tm_zone->dst : 0)), zp);
|
||||
if (zp->west || zp->dst)
|
||||
flags &= ~TM_UTC;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
p = (flags & TM_UTC) ? tm_info.format[TM_UT] : tm->tm_isdst && tm->tm_zone->daylight ? tm->tm_zone->daylight : tm->tm_zone->standard;
|
||||
p = (flags & TM_UTC) ? tm_info.local->standard : tm->tm_isdst && tm->tm_zone->daylight ? tm->tm_zone->daylight : tm->tm_zone->standard;
|
||||
goto string;
|
||||
case '=': /* (AST) OBSOLETE use %([+-]flag...)Qo (old %=[=][+-]flag) */
|
||||
for (arg = argbuf; *format == '=' || *format == '-' || *format == '+' || *format == '!'; format++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue