Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
14eb94ee
Commit
14eb94ee
authored
Apr 09, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `gmtime` issues in Win32
parent
8416c9ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
src/signature.c
+20
-6
No files found.
src/signature.c
View file @
14eb94ee
...
...
@@ -68,18 +68,32 @@ git_signature *git_signature_dup(const git_signature *sig)
git_signature
*
git_signature_now
(
const
char
*
name
,
const
char
*
email
)
{
time_t
now
;
struct
tm
utc_tm
,
local_tm
;
int
offset
;
struct
tm
*
utc_tm
,
*
local_tm
;
time
(
&
now
);
#ifndef GIT_WIN32
struct
tm
_utc
,
_local
;
#endif
gmtime_r
(
&
now
,
&
utc_tm
);
localtime_r
(
&
now
,
&
local_tm
);
time
(
&
now
);
offset
=
mktime
(
&
local_tm
)
-
mktime
(
&
utc_tm
);
/**
* On Win32, `gmtime_r` doesn't exist but
* `gmtime` is threadsafe, so we can use that
*/
#ifdef GIT_WIN32
utc_tm
=
gmtime
(
&
now
);
local_tm
=
localtime
(
&
now
);
#else
utc_tm
=
gmtime_r
(
&
now
,
&
_utc
);
local_tm
=
localtime_r
(
&
now
,
&
_local
);
#endif
offset
=
mktime
(
local_tm
)
-
mktime
(
utc_tm
);
offset
/=
60
;
/* mktime takes care of setting tm_isdst correctly */
if
(
local_tm
.
tm_isdst
)
if
(
local_tm
->
tm_isdst
)
offset
+=
60
;
return
git_signature_new
(
name
,
email
,
now
,
offset
);
...
...
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