Are there any standard (C, C++, POSIX, Linux...) alternatives to strftime which can be used to
- calculate the required size of the string buffer for a given format and time,
- truncate the output (instead of leaving the array contents undefined like
strftimedoes) if buffer size is less than required for full output.
For example, snprintf-like semantics for date/time formatting which accept strftime format strings would do perfectly.
Functions like std::put_time in C++11 and later are not an option, because these may attempt to allocate extra memory dynamically and may throw exceptions.