Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4921 → Rev 6099

/contrib/sdk/sources/newlib/libc/time/strftime.c
166,6 → 166,10
o %R
The 24-hour time, to the minute. Equivalent to "%H:%M". [tm_min, tm_hour]
 
o %s
The time elapsed, in seconds, since the start of the Unix epoch at
1970-01-01 00:00:00 UTC.
 
o %S
The second, formatted with two digits (from `<<00>>' to `<<60>>'). The
value 60 accounts for the occasional leap second. [tm_sec]
694,15 → 698,16
#endif /* !_WANT_C99_TIME_FORMATS */
{
size_t count = 0;
int i, len = 0;
int len = 0;
const CHAR *ctloc;
#if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__)
CHAR ctlocbuf[CTLOCBUFLEN];
#endif
size_t ctloclen;
size_t i, ctloclen;
CHAR alt;
CHAR pad;
unsigned long width;
int tzset_called = 0;
 
struct lc_time_T *_CurrentTimeLocale = __get_current_time_locale ();
for (;;)
1108,6 → 1113,74
tim_p->tm_hour, tim_p->tm_min);
CHECK_LENGTH ();
break;
case CQ('s'):
/*
* From:
* The Open Group Base Specifications Issue 7
* IEEE Std 1003.1, 2013 Edition
* Copyright (c) 2001-2013 The IEEE and The Open Group
* XBD Base Definitions
* 4. General Concepts
* 4.15 Seconds Since the Epoch
* A value that approximates the number of seconds that have elapsed since the
* Epoch. A Coordinated Universal Time name (specified in terms of seconds
* (tm_sec), minutes (tm_min), hours (tm_hour), days since January 1 of the year
* (tm_yday), and calendar year minus 1900 (tm_year)) is related to a time
* represented as seconds since the Epoch, according to the expression below.
* If the year is <1970 or the value is negative, the relationship is undefined.
* If the year is >=1970 and the value is non-negative, the value is related to a
* Coordinated Universal Time name according to the C-language expression, where
* tm_sec, tm_min, tm_hour, tm_yday, and tm_year are all integer types:
* tm_sec + tm_min*60 + tm_hour*3600 + tm_yday*86400 +
* (tm_year-70)*31536000 + ((tm_year-69)/4)*86400 -
* ((tm_year-1)/100)*86400 + ((tm_year+299)/400)*86400
* OR
* ((((tm_year-69)/4 - (tm_year-1)/100 + (tm_year+299)/400 +
* (tm_year-70)*365 + tm_yday)*24 + tm_hour)*60 + tm_min)*60 + tm_sec
*/
/* modified from %z case by hoisting offset outside if block and initializing */
{
long offset = 0; /* offset < 0 => W of GMT, > 0 => E of GMT:
subtract to get UTC */
 
if (tim_p->tm_isdst >= 0)
{
TZ_LOCK;
if (!tzset_called)
{
_tzset_unlocked ();
tzset_called = 1;
}
 
#if defined (__CYGWIN__)
/* Cygwin must check if the application has been built with or
without the extra tm members for backward compatibility, and
then use either that or the old method fetching from tzinfo.
Rather than pulling in the version check infrastructure, we
just call a Cygwin function. */
extern long __cygwin_gettzoffset (const struct tm *tmp);
offset = __cygwin_gettzoffset (tim_p);
#elif defined (__TM_GMTOFF)
offset = tim_p->__TM_GMTOFF;
#else
__tzinfo_type *tz = __gettzinfo ();
/* The sign of this is exactly opposite the envvar TZ. We
could directly use the global _timezone for tm_isdst==0,
but have to use __tzrule for daylight savings. */
offset = -tz->__tzrule[tim_p->tm_isdst > 0].offset;
#endif
TZ_UNLOCK;
}
len = snprintf (&s[count], maxsize - count, CQ("%lld"),
(((((long long)tim_p->tm_year - 69)/4
- (tim_p->tm_year - 1)/100
+ (tim_p->tm_year + 299)/400
+ (tim_p->tm_year - 70)*365 + tim_p->tm_yday)*24
+ tim_p->tm_hour)*60 + tim_p->tm_min)*60
+ tim_p->tm_sec - offset);
CHECK_LENGTH ();
}
break;
case CQ('S'):
#ifdef _WANT_C99_TIME_FORMATS
if (alt != CQ('O') || !*alt_digits
1283,12 → 1356,31
if (tim_p->tm_isdst >= 0)
{
long offset;
 
TZ_LOCK;
if (!tzset_called)
{
_tzset_unlocked ();
tzset_called = 1;
}
 
#if defined (__CYGWIN__)
/* Cygwin must check if the application has been built with or
without the extra tm members for backward compatibility, and
then use either that or the old method fetching from tzinfo.
Rather than pulling in the version check infrastructure, we
just call a Cygwin function. */
extern long __cygwin_gettzoffset (const struct tm *tmp);
offset = __cygwin_gettzoffset (tim_p);
#elif defined (__TM_GMTOFF)
offset = tim_p->__TM_GMTOFF;
#else
__tzinfo_type *tz = __gettzinfo ();
TZ_LOCK;
/* The sign of this is exactly opposite the envvar TZ. We
could directly use the global _timezone for tm_isdst==0,
but have to use __tzrule for daylight savings. */
offset = -tz->__tzrule[tim_p->tm_isdst > 0].offset;
#endif
TZ_UNLOCK;
len = snprintf (&s[count], maxsize - count, CQ("%+03ld%.2ld"),
offset / SECSPERHOUR,
1299,13 → 1391,33
case CQ('Z'):
if (tim_p->tm_isdst >= 0)
{
int size;
size_t size;
const char *tznam = NULL;
 
TZ_LOCK;
size = strlen(_tzname[tim_p->tm_isdst > 0]);
if (!tzset_called)
{
_tzset_unlocked ();
tzset_called = 1;
}
#if defined (__CYGWIN__)
/* See above. */
extern const char *__cygwin_gettzname (const struct tm *tmp);
tznam = __cygwin_gettzname (tim_p);
#elif defined (__TM_ZONE)
tznam = tim_p->__TM_ZONE;
#endif
if (!tznam)
tznam = _tzname[tim_p->tm_isdst > 0];
/* Note that in case of wcsftime this loop only works for
timezone abbreviations using the portable codeset (aka ASCII).
This seems to be the case, but if that ever changes, this
loop needs revisiting. */
size = strlen (tznam);
for (i = 0; i < size; i++)
{
if (count < maxsize - 1)
s[count++] = _tzname[tim_p->tm_isdst > 0][i];
s[count++] = tznam[i];
else
{
TZ_UNLOCK;
1402,6 → 1514,7
{ CQ("%p"), 2+1, EXP(CQ("AM")) },
{ CQ("%r"), 11+1, EXP(CQ("09:53:47 AM")) },
{ CQ("%R"), 5+1, EXP(CQ("09:53")) },
{ CQ("%s"), 2+1, EXP(CQ("1230648827")) },
{ CQ("%S"), 2+1, EXP(CQ("47")) },
{ CQ("%t"), 1+1, EXP(CQ("\t")) },
{ CQ("%T"), 8+1, EXP(CQ("09:53:47")) },
1462,6 → 1575,7
{ CQ("%p"), 2+1, EXP(CQ("PM")) },
{ CQ("%r"), 11+1, EXP(CQ("11:01:13 PM")) },
{ CQ("%R"), 5+1, EXP(CQ("23:01")) },
{ CQ("%s"), 2+1, EXP(CQ("1215054073")) },
{ CQ("%S"), 2+1, EXP(CQ("13")) },
{ CQ("%t"), 1+1, EXP(CQ("\t")) },
{ CQ("%T"), 8+1, EXP(CQ("23:01:13")) },