Rev 4921 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4921 | Rev 6099 | ||
---|---|---|---|
Line 164... | Line 164... | ||
164 | notations, the result is an empty string. [tm_sec, tm_min, tm_hour] |
164 | notations, the result is an empty string. [tm_sec, tm_min, tm_hour] |
Line 165... | Line 165... | ||
165 | 165 | ||
166 | o %R |
166 | o %R |
Line -... | Line 167... | ||
- | 167 | The 24-hour time, to the minute. Equivalent to "%H:%M". [tm_min, tm_hour] |
|
- | 168 | ||
- | 169 | o %s |
|
- | 170 | The time elapsed, in seconds, since the start of the Unix epoch at |
|
167 | The 24-hour time, to the minute. Equivalent to "%H:%M". [tm_min, tm_hour] |
171 | 1970-01-01 00:00:00 UTC. |
168 | 172 | ||
169 | o %S |
173 | o %S |
Line 170... | Line 174... | ||
170 | The second, formatted with two digits (from `<<00>>' to `<<60>>'). The |
174 | The second, formatted with two digits (from `<<00>>' to `<<60>>'). The |
Line 692... | Line 696... | ||
692 | _CONST CHAR *__restrict format _AND |
696 | _CONST CHAR *__restrict format _AND |
693 | _CONST struct tm *__restrict tim_p) |
697 | _CONST struct tm *__restrict tim_p) |
694 | #endif /* !_WANT_C99_TIME_FORMATS */ |
698 | #endif /* !_WANT_C99_TIME_FORMATS */ |
695 | { |
699 | { |
696 | size_t count = 0; |
700 | size_t count = 0; |
697 | int i, len = 0; |
701 | int len = 0; |
698 | const CHAR *ctloc; |
702 | const CHAR *ctloc; |
699 | #if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) |
703 | #if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) |
700 | CHAR ctlocbuf[CTLOCBUFLEN]; |
704 | CHAR ctlocbuf[CTLOCBUFLEN]; |
701 | #endif |
705 | #endif |
702 | size_t ctloclen; |
706 | size_t i, ctloclen; |
703 | CHAR alt; |
707 | CHAR alt; |
704 | CHAR pad; |
708 | CHAR pad; |
705 | unsigned long width; |
709 | unsigned long width; |
- | 710 | int tzset_called = 0; |
|
Line 706... | Line 711... | ||
706 | 711 | ||
707 | struct lc_time_T *_CurrentTimeLocale = __get_current_time_locale (); |
712 | struct lc_time_T *_CurrentTimeLocale = __get_current_time_locale (); |
708 | for (;;) |
713 | for (;;) |
709 | { |
714 | { |
Line 1106... | Line 1111... | ||
1106 | case CQ('R'): |
1111 | case CQ('R'): |
1107 | len = snprintf (&s[count], maxsize - count, CQ("%.2d:%.2d"), |
1112 | len = snprintf (&s[count], maxsize - count, CQ("%.2d:%.2d"), |
1108 | tim_p->tm_hour, tim_p->tm_min); |
1113 | tim_p->tm_hour, tim_p->tm_min); |
1109 | CHECK_LENGTH (); |
1114 | CHECK_LENGTH (); |
1110 | break; |
1115 | break; |
- | 1116 | case CQ('s'): |
|
- | 1117 | /* |
|
- | 1118 | * From: |
|
- | 1119 | * The Open Group Base Specifications Issue 7 |
|
- | 1120 | * IEEE Std 1003.1, 2013 Edition |
|
- | 1121 | * Copyright (c) 2001-2013 The IEEE and The Open Group |
|
- | 1122 | * XBD Base Definitions |
|
- | 1123 | * 4. General Concepts |
|
- | 1124 | * 4.15 Seconds Since the Epoch |
|
- | 1125 | * A value that approximates the number of seconds that have elapsed since the |
|
- | 1126 | * Epoch. A Coordinated Universal Time name (specified in terms of seconds |
|
- | 1127 | * (tm_sec), minutes (tm_min), hours (tm_hour), days since January 1 of the year |
|
- | 1128 | * (tm_yday), and calendar year minus 1900 (tm_year)) is related to a time |
|
- | 1129 | * represented as seconds since the Epoch, according to the expression below. |
|
- | 1130 | * If the year is <1970 or the value is negative, the relationship is undefined. |
|
- | 1131 | * If the year is >=1970 and the value is non-negative, the value is related to a |
|
- | 1132 | * Coordinated Universal Time name according to the C-language expression, where |
|
- | 1133 | * tm_sec, tm_min, tm_hour, tm_yday, and tm_year are all integer types: |
|
- | 1134 | * tm_sec + tm_min*60 + tm_hour*3600 + tm_yday*86400 + |
|
- | 1135 | * (tm_year-70)*31536000 + ((tm_year-69)/4)*86400 - |
|
- | 1136 | * ((tm_year-1)/100)*86400 + ((tm_year+299)/400)*86400 |
|
- | 1137 | * OR |
|
- | 1138 | * ((((tm_year-69)/4 - (tm_year-1)/100 + (tm_year+299)/400 + |
|
- | 1139 | * (tm_year-70)*365 + tm_yday)*24 + tm_hour)*60 + tm_min)*60 + tm_sec |
|
- | 1140 | */ |
|
- | 1141 | /* modified from %z case by hoisting offset outside if block and initializing */ |
|
- | 1142 | { |
|
- | 1143 | long offset = 0; /* offset < 0 => W of GMT, > 0 => E of GMT: |
|
- | 1144 | subtract to get UTC */ |
|
- | 1145 | ||
- | 1146 | if (tim_p->tm_isdst >= 0) |
|
- | 1147 | { |
|
- | 1148 | TZ_LOCK; |
|
- | 1149 | if (!tzset_called) |
|
- | 1150 | { |
|
- | 1151 | _tzset_unlocked (); |
|
- | 1152 | tzset_called = 1; |
|
- | 1153 | } |
|
- | 1154 | ||
- | 1155 | #if defined (__CYGWIN__) |
|
- | 1156 | /* Cygwin must check if the application has been built with or |
|
- | 1157 | without the extra tm members for backward compatibility, and |
|
- | 1158 | then use either that or the old method fetching from tzinfo. |
|
- | 1159 | Rather than pulling in the version check infrastructure, we |
|
- | 1160 | just call a Cygwin function. */ |
|
- | 1161 | extern long __cygwin_gettzoffset (const struct tm *tmp); |
|
- | 1162 | offset = __cygwin_gettzoffset (tim_p); |
|
- | 1163 | #elif defined (__TM_GMTOFF) |
|
- | 1164 | offset = tim_p->__TM_GMTOFF; |
|
- | 1165 | #else |
|
- | 1166 | __tzinfo_type *tz = __gettzinfo (); |
|
- | 1167 | /* The sign of this is exactly opposite the envvar TZ. We |
|
- | 1168 | could directly use the global _timezone for tm_isdst==0, |
|
- | 1169 | but have to use __tzrule for daylight savings. */ |
|
- | 1170 | offset = -tz->__tzrule[tim_p->tm_isdst > 0].offset; |
|
- | 1171 | #endif |
|
- | 1172 | TZ_UNLOCK; |
|
- | 1173 | } |
|
- | 1174 | len = snprintf (&s[count], maxsize - count, CQ("%lld"), |
|
- | 1175 | (((((long long)tim_p->tm_year - 69)/4 |
|
- | 1176 | - (tim_p->tm_year - 1)/100 |
|
- | 1177 | + (tim_p->tm_year + 299)/400 |
|
- | 1178 | + (tim_p->tm_year - 70)*365 + tim_p->tm_yday)*24 |
|
- | 1179 | + tim_p->tm_hour)*60 + tim_p->tm_min)*60 |
|
- | 1180 | + tim_p->tm_sec - offset); |
|
- | 1181 | CHECK_LENGTH (); |
|
- | 1182 | } |
|
- | 1183 | break; |
|
1111 | case CQ('S'): |
1184 | case CQ('S'): |
1112 | #ifdef _WANT_C99_TIME_FORMATS |
1185 | #ifdef _WANT_C99_TIME_FORMATS |
1113 | if (alt != CQ('O') || !*alt_digits |
1186 | if (alt != CQ('O') || !*alt_digits |
1114 | || !(len = conv_to_alt_digits (&s[count], maxsize - count, |
1187 | || !(len = conv_to_alt_digits (&s[count], maxsize - count, |
1115 | tim_p->tm_sec, *alt_digits))) |
1188 | tim_p->tm_sec, *alt_digits))) |
Line 1281... | Line 1354... | ||
1281 | break; |
1354 | break; |
1282 | case CQ('z'): |
1355 | case CQ('z'): |
1283 | if (tim_p->tm_isdst >= 0) |
1356 | if (tim_p->tm_isdst >= 0) |
1284 | { |
1357 | { |
1285 | long offset; |
1358 | long offset; |
1286 | __tzinfo_type *tz = __gettzinfo (); |
- | |
- | 1359 | ||
1287 | TZ_LOCK; |
1360 | TZ_LOCK; |
- | 1361 | if (!tzset_called) |
|
- | 1362 | { |
|
- | 1363 | _tzset_unlocked (); |
|
- | 1364 | tzset_called = 1; |
|
- | 1365 | } |
|
- | 1366 | ||
- | 1367 | #if defined (__CYGWIN__) |
|
- | 1368 | /* Cygwin must check if the application has been built with or |
|
- | 1369 | without the extra tm members for backward compatibility, and |
|
- | 1370 | then use either that or the old method fetching from tzinfo. |
|
- | 1371 | Rather than pulling in the version check infrastructure, we |
|
- | 1372 | just call a Cygwin function. */ |
|
- | 1373 | extern long __cygwin_gettzoffset (const struct tm *tmp); |
|
- | 1374 | offset = __cygwin_gettzoffset (tim_p); |
|
- | 1375 | #elif defined (__TM_GMTOFF) |
|
- | 1376 | offset = tim_p->__TM_GMTOFF; |
|
- | 1377 | #else |
|
- | 1378 | __tzinfo_type *tz = __gettzinfo (); |
|
1288 | /* The sign of this is exactly opposite the envvar TZ. We |
1379 | /* The sign of this is exactly opposite the envvar TZ. We |
1289 | could directly use the global _timezone for tm_isdst==0, |
1380 | could directly use the global _timezone for tm_isdst==0, |
1290 | but have to use __tzrule for daylight savings. */ |
1381 | but have to use __tzrule for daylight savings. */ |
1291 | offset = -tz->__tzrule[tim_p->tm_isdst > 0].offset; |
1382 | offset = -tz->__tzrule[tim_p->tm_isdst > 0].offset; |
- | 1383 | #endif |
|
1292 | TZ_UNLOCK; |
1384 | TZ_UNLOCK; |
1293 | len = snprintf (&s[count], maxsize - count, CQ("%+03ld%.2ld"), |
1385 | len = snprintf (&s[count], maxsize - count, CQ("%+03ld%.2ld"), |
1294 | offset / SECSPERHOUR, |
1386 | offset / SECSPERHOUR, |
1295 | labs (offset / SECSPERMIN) % 60L); |
1387 | labs (offset / SECSPERMIN) % 60L); |
1296 | CHECK_LENGTH (); |
1388 | CHECK_LENGTH (); |
1297 | } |
1389 | } |
1298 | break; |
1390 | break; |
1299 | case CQ('Z'): |
1391 | case CQ('Z'): |
1300 | if (tim_p->tm_isdst >= 0) |
1392 | if (tim_p->tm_isdst >= 0) |
1301 | { |
1393 | { |
1302 | int size; |
1394 | size_t size; |
- | 1395 | const char *tznam = NULL; |
|
- | 1396 | ||
1303 | TZ_LOCK; |
1397 | TZ_LOCK; |
- | 1398 | if (!tzset_called) |
|
- | 1399 | { |
|
- | 1400 | _tzset_unlocked (); |
|
- | 1401 | tzset_called = 1; |
|
- | 1402 | } |
|
- | 1403 | #if defined (__CYGWIN__) |
|
- | 1404 | /* See above. */ |
|
- | 1405 | extern const char *__cygwin_gettzname (const struct tm *tmp); |
|
- | 1406 | tznam = __cygwin_gettzname (tim_p); |
|
- | 1407 | #elif defined (__TM_ZONE) |
|
- | 1408 | tznam = tim_p->__TM_ZONE; |
|
- | 1409 | #endif |
|
- | 1410 | if (!tznam) |
|
1304 | size = strlen(_tzname[tim_p->tm_isdst > 0]); |
1411 | tznam = _tzname[tim_p->tm_isdst > 0]; |
- | 1412 | /* Note that in case of wcsftime this loop only works for |
|
- | 1413 | timezone abbreviations using the portable codeset (aka ASCII). |
|
- | 1414 | This seems to be the case, but if that ever changes, this |
|
- | 1415 | loop needs revisiting. */ |
|
- | 1416 | size = strlen (tznam); |
|
1305 | for (i = 0; i < size; i++) |
1417 | for (i = 0; i < size; i++) |
1306 | { |
1418 | { |
1307 | if (count < maxsize - 1) |
1419 | if (count < maxsize - 1) |
1308 | s[count++] = _tzname[tim_p->tm_isdst > 0][i]; |
1420 | s[count++] = tznam[i]; |
1309 | else |
1421 | else |
1310 | { |
1422 | { |
1311 | TZ_UNLOCK; |
1423 | TZ_UNLOCK; |
1312 | return 0; |
1424 | return 0; |
1313 | } |
1425 | } |
Line 1400... | Line 1512... | ||
1400 | { CQ("%M"), 2+1, EXP(CQ("53")) }, |
1512 | { CQ("%M"), 2+1, EXP(CQ("53")) }, |
1401 | { CQ("%n"), 1+1, EXP(CQ("\n")) }, |
1513 | { CQ("%n"), 1+1, EXP(CQ("\n")) }, |
1402 | { CQ("%p"), 2+1, EXP(CQ("AM")) }, |
1514 | { CQ("%p"), 2+1, EXP(CQ("AM")) }, |
1403 | { CQ("%r"), 11+1, EXP(CQ("09:53:47 AM")) }, |
1515 | { CQ("%r"), 11+1, EXP(CQ("09:53:47 AM")) }, |
1404 | { CQ("%R"), 5+1, EXP(CQ("09:53")) }, |
1516 | { CQ("%R"), 5+1, EXP(CQ("09:53")) }, |
- | 1517 | { CQ("%s"), 2+1, EXP(CQ("1230648827")) }, |
|
1405 | { CQ("%S"), 2+1, EXP(CQ("47")) }, |
1518 | { CQ("%S"), 2+1, EXP(CQ("47")) }, |
1406 | { CQ("%t"), 1+1, EXP(CQ("\t")) }, |
1519 | { CQ("%t"), 1+1, EXP(CQ("\t")) }, |
1407 | { CQ("%T"), 8+1, EXP(CQ("09:53:47")) }, |
1520 | { CQ("%T"), 8+1, EXP(CQ("09:53:47")) }, |
1408 | { CQ("%u"), 1+1, EXP(CQ("2")) }, |
1521 | { CQ("%u"), 1+1, EXP(CQ("2")) }, |
1409 | { CQ("%U"), 2+1, EXP(CQ("52")) }, |
1522 | { CQ("%U"), 2+1, EXP(CQ("52")) }, |
Line 1460... | Line 1573... | ||
1460 | { CQ("%M"), 2+1, EXP(CQ("01")) }, |
1573 | { CQ("%M"), 2+1, EXP(CQ("01")) }, |
1461 | { CQ("%n"), 1+1, EXP(CQ("\n")) }, |
1574 | { CQ("%n"), 1+1, EXP(CQ("\n")) }, |
1462 | { CQ("%p"), 2+1, EXP(CQ("PM")) }, |
1575 | { CQ("%p"), 2+1, EXP(CQ("PM")) }, |
1463 | { CQ("%r"), 11+1, EXP(CQ("11:01:13 PM")) }, |
1576 | { CQ("%r"), 11+1, EXP(CQ("11:01:13 PM")) }, |
1464 | { CQ("%R"), 5+1, EXP(CQ("23:01")) }, |
1577 | { CQ("%R"), 5+1, EXP(CQ("23:01")) }, |
- | 1578 | { CQ("%s"), 2+1, EXP(CQ("1215054073")) }, |
|
1465 | { CQ("%S"), 2+1, EXP(CQ("13")) }, |
1579 | { CQ("%S"), 2+1, EXP(CQ("13")) }, |
1466 | { CQ("%t"), 1+1, EXP(CQ("\t")) }, |
1580 | { CQ("%t"), 1+1, EXP(CQ("\t")) }, |
1467 | { CQ("%T"), 8+1, EXP(CQ("23:01:13")) }, |
1581 | { CQ("%T"), 8+1, EXP(CQ("23:01:13")) }, |
1468 | { CQ("%u"), 1+1, EXP(CQ("3")) }, |
1582 | { CQ("%u"), 1+1, EXP(CQ("3")) }, |
1469 | { CQ("%U"), 2+1, EXP(CQ("26")) }, |
1583 | { CQ("%U"), 2+1, EXP(CQ("26")) }, |