Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
e11834d1
Commit
e11834d1
authored
Nov 24, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Add code in case struct tm.tm_gmtoff is not available
parent
8f22ff30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
configure.ac
configure.ac
+8
-0
src/util.cc
src/util.cc
+32
-0
No files found.
configure.ac
View file @
e11834d1
...
...
@@ -468,6 +468,14 @@ AC_CHECK_TYPES([ptrdiff_t])
AC_C_BIGENDIAN
AC_SYS_LARGEFILE
AC_CHECK_MEMBER([struct tm.tm_gmtoff], [have_struct_tm_tm_gmtoff=yes],
[have_struct_tm_tm_gmtoff=no], [[#include <time.h>]])
if test "x$have_struct_tm_tm_gmtoff" = "xyes"; then
AC_DEFINE([HAVE_STRUCT_TM_TM_GMTOFF], [1],
[Define to 1 if you have `struct tm.tm_gmtoff` member.])
fi
# Checks for library functions.
if test "x$cross_compiling" != "xyes"; then
AC_FUNC_MALLOC
...
...
src/util.cc
View file @
e11834d1
...
...
@@ -231,6 +231,7 @@ std::string common_log_date(time_t t)
return
""
;
}
#ifdef HAVE_STRUCT_TM_TM_GMTOFF
// Format data like this:
// 03/Jul/2014:00:19:38 +0900
std
::
string
res
;
...
...
@@ -264,6 +265,13 @@ std::string common_log_date(time_t t)
p
=
cpydig
(
p
,
(
gmtoff
%
3600
)
/
60
,
2
);
return
res
;
#else // !HAVE_STRUCT_TM_TM_GMTOFF
char
buf
[
32
];
strftime
(
buf
,
sizeof
(
buf
),
"%d/%b/%Y:%T %z"
,
&
tms
);
return
buf
;
#endif // !HAVE_STRUCT_TM_TM_GMTOFF
}
std
::
string
iso8601_date
(
int64_t
ms
)
...
...
@@ -275,6 +283,7 @@ std::string iso8601_date(int64_t ms)
return
""
;
}
#ifdef HAVE_STRUCT_TM_TM_GMTOFF
// Format data like this:
// 2014-11-15T12:58:24.741Z
// 2014-11-15T12:58:24.741+09:00
...
...
@@ -315,6 +324,29 @@ std::string iso8601_date(int64_t ms)
res
.
resize
(
p
-
std
::
begin
(
res
));
return
res
;
#else // !HAVE_STRUCT_TM_TM_GMTOFF
char
buf
[
128
];
auto
nwrite
=
strftime
(
buf
,
sizeof
(
buf
),
"%Y-%m-%dT%H:%M:%S"
,
&
tms
);
nwrite
+=
snprintf
(
&
buf
[
nwrite
],
sizeof
(
buf
)
-
nwrite
,
".%03d"
,
static_cast
<
int
>
(
ms
%
1000
));
auto
nzone
=
strftime
(
&
buf
[
nwrite
],
sizeof
(
buf
)
-
nwrite
,
"%z"
,
&
tms
);
// %z of strftime writes +hhmm or -hhmm not Z, +hh:mm or -hh:mm. Do
// %nothing if nzone is not 5. we don't know how to cope with this.
if
(
nzone
==
5
)
{
if
(
memcmp
(
&
buf
[
nwrite
],
"+0000"
,
5
)
==
0
)
{
// 0000 should be Z
memcpy
(
&
buf
[
nwrite
],
"Z"
,
2
);
}
else
{
// Move mm part to right by 1 including terminal \0
memmove
(
&
buf
[
nwrite
+
4
],
&
buf
[
nwrite
+
3
],
3
);
// Insert ':' between hh and mm
buf
[
nwrite
+
3
]
=
':'
;
}
}
return
buf
;
#endif // !HAVE_STRUCT_TM_TM_GMTOFF
}
time_t
parse_http_date
(
const
std
::
string
&
s
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment