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. */
| 910 | fit, return the length that the string would have been if it had |
| 911 | fit; do not overrun the output buffer. */ |
| 912 | static int |
| 913 | format_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 |