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

Function format_local_time

zdump.c:912–921  ·  view source on GitHub ↗

Store into BUF, of size SIZE, a formatted local time taken from *TM. Use ISO 8601 format +HH:MM:SS. Omit :SS if SS is zero, and omit :MM too if MM is also zero. Return the length of the resulting string. If the string does not fit, return the length that the string would have been if it had fit; do not overrun the output buffer. */

Source from the content-addressed store, hash-verified

910 fit, return the length that the string would have been if it had
911 fit; do not overrun the output buffer. */
912static int
913format_local_time(char *buf, ptrdiff_t size, struct tm const *tm)
914{
915 int ss = tm->tm_sec, mm = tm->tm_min, hh = tm->tm_hour;
916 return (ss
917 ? snprintf(buf, size, "%02d:%02d:%02d", hh, mm, ss)
918 : mm
919 ? snprintf(buf, size, "%02d:%02d", hh, mm)
920 : snprintf(buf, size, "%02d", hh));
921}
922
923/* Store into BUF, of size SIZE, a formatted UT offset for the
924 localtime *TM corresponding to time T. Use ISO 8601 format

Callers 1

istrftimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected