mirror of
https://github.com/curl/curl.git
synced 2026-07-28 07:23:07 +03:00
make %z portable
This commit is contained in:
parent
3c92c60a1f
commit
958b3c1105
3 changed files with 13 additions and 8 deletions
|
|
@ -532,4 +532,4 @@ from UTC). As time is always UTC, this outputs `+0000`.
|
|||
|
||||
## `%Z`
|
||||
|
||||
The timezone name, meaning `UTC`.
|
||||
The timezone name. For some reason `GMT`.
|
||||
|
|
|
|||
|
|
@ -584,13 +584,18 @@ static const char *outtime(const char *ptr, /* %time{ ... */
|
|||
curlx_dyn_init(&format, 1024);
|
||||
|
||||
/* insert sub-seconds for %f */
|
||||
/* insert +0000 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') {
|
||||
result = curlx_dyn_addf(&format, "%06u", usecs);
|
||||
if((i < vlen - 1) && ptr[i] == '%' &&
|
||||
((ptr[i + 1] == 'f') || (ptr[i + 1] == 'z'))) {
|
||||
if(ptr[i + 1] == 'f')
|
||||
result = curlx_dyn_addf(&format, "%06u", usecs);
|
||||
else
|
||||
result = curlx_dyn_addn(&format, "+0000", 5);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
result = curlx_dyn_addn(&format, &ptr[i], 1);
|
||||
else
|
||||
result = curlx_dyn_addn(&format, &ptr[i], 1);
|
||||
}
|
||||
if(!result) {
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ http
|
|||
Debug
|
||||
</features>
|
||||
<setenv>
|
||||
CURL_TIME=1754037100
|
||||
CURL_TIME=1754037103
|
||||
</setenv>
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/%TESTNUMBER --write-out='Time: %time{%d/%b/%Y %H:%M:%S.%f %z}\n' -s -o %LOGDIR/dump
|
||||
http://%HOSTIP:%HTTPPORT/%TESTNUMBER --write-out='Time: %time{%d/%b/%Y %H:%M:%S.%f %z %Z}\n' -s -o %LOGDIR/dump
|
||||
</command>
|
||||
</client>
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ Accept: */*
|
|||
|
||||
</protocol>
|
||||
<stdout mode="text">
|
||||
Time: 01/Aug/2025 08:31:40.037100 +0000
|
||||
Time: 01/Aug/2025 08:31:43.037103 +0000 GMT
|
||||
</stdout>
|
||||
</verify>
|
||||
</testcase>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue