MCPcopy Create free account
hub / github.com/eggert/tz / tformat

Function tformat

zdump.c:1126–1164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1124*/
1125
1126static const char *
1127tformat(void)
1128{
1129#if HAVE__GENERIC
1130 /* C11-style _Generic is more likely to return the correct
1131 format when distinct types have the same size. */
1132 char const *fmt =
1133 _Generic(+ (time_t) 0,
1134 int: "%d", long: "%ld", long long: "%lld",
1135 unsigned: "%u", unsigned long: "%lu",
1136 unsigned long long: "%llu",
1137 default: NULL);
1138 if (fmt)
1139 return fmt;
1140 fmt = _Generic((time_t) 0,
1141 intmax_t: "%"PRIdMAX, uintmax_t: "%"PRIuMAX,
1142 default: NULL);
1143 if (fmt)
1144 return fmt;
1145#endif
1146 if (0 > (time_t) -1) { /* signed */
1147 if (sizeof(time_t) == sizeof(intmax_t))
1148 return "%"PRIdMAX;
1149 if (sizeof(time_t) > sizeof(long))
1150 return "%lld";
1151 if (sizeof(time_t) > sizeof(int))
1152 return "%ld";
1153 return "%d";
1154 }
1155#ifdef PRIuMAX
1156 if (sizeof(time_t) == sizeof(uintmax_t))
1157 return "%"PRIuMAX;
1158#endif
1159 if (sizeof(time_t) > sizeof(unsigned long))
1160 return "%llu";
1161 if (sizeof(time_t) > sizeof(unsigned int))
1162 return "%lu";
1163 return "%u";
1164}
1165
1166static void
1167dumptime(register const struct tm *timeptr)

Callers 2

showFunction · 0.85
showtransFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected