I'd like to format the 2023/10/04T11:41:03.553Z with strptime(3) %Y/%m/%dT%H:%M:%S.???Z.
What is the input field descriptor of fraction of seconds ?
Although I read through the document of strptime(3), I couldn't find any input field descriptor which corresponds to "millisecond".
Function
strptime()in not part of any Standard C library. It is well defined in*nixsystems. It commonly uses a pointer tostruct tm.struct tmis defined to have at least 9 members. It may have more. There is no specified member corresponding to time units finer than seconds.Sometimes
struct tmhas a member for milliseconds, microseconds, etc. Yet that is implementation dependent.Referenced
strptime()simply does not have a specifier for sub-seconds. Code needs to handle such optional members in some other fashion.struct tmwoesWithout
"%Z",strptime()forms thestruct tmwithout adjusting.tm_isdst. In general,strptime()does not certainly assign allstruct tmmembers.Initialize
struct tmprior to thestrptime().Sample validation:
For the pedantic: detect rump milliseconds as exactly as 3 digits.