make %Z portable too

This commit is contained in:
Daniel Stenberg 2025-08-01 17:04:56 +02:00
parent 958b3c1105
commit 5eec4c04db
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 5 additions and 2 deletions

View file

@ -585,11 +585,14 @@ static const char *outtime(const char *ptr, /* %time{ ... */
/* insert sub-seconds for %f */
/* insert +0000 for %z because it is otherwise not portable */
/* insert UTC for %Z because it is otherwise not portable */
for(i = 0; !result && i < vlen; i++) {
if((i < vlen - 1) && ptr[i] == '%' &&
((ptr[i + 1] == 'f') || (ptr[i + 1] == 'z'))) {
((ptr[i + 1] == 'f') || ((ptr[i + 1] | 0x20) == 'z'))) {
if(ptr[i + 1] == 'f')
result = curlx_dyn_addf(&format, "%06u", usecs);
else if(ptr[i + 1] == 'Z')
result = curlx_dyn_addn(&format, "UTC", 3);
else
result = curlx_dyn_addn(&format, "+0000", 5);
i++;

View file

@ -56,7 +56,7 @@ Accept: */*
</protocol>
<stdout mode="text">
Time: 01/Aug/2025 08:31:43.037103 +0000 GMT
Time: 01/Aug/2025 08:31:43.037103 +0000 UTC
</stdout>
</verify>
</testcase>