src: Use gmtime_r instead of gmtime
src: Eliminate use of snprintf
src: Rewrite util::format_hex