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
319ad0ba
Commit
319ad0ba
authored
Aug 28, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #905 from carlosmn/signature-now
signature: make the OS give us the offset for git_signature_now
parents
0844ed06
d03d309b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
src/signature.c
+12
-10
No files found.
src/signature.c
View file @
319ad0ba
...
@@ -125,24 +125,26 @@ int git_signature_now(git_signature **sig_out, const char *name, const char *ema
...
@@ -125,24 +125,26 @@ int git_signature_now(git_signature **sig_out, const char *name, const char *ema
{
{
time_t
now
;
time_t
now
;
time_t
offset
;
time_t
offset
;
struct
tm
*
utc_tm
,
*
local_tm
;
struct
tm
*
utc_tm
;
git_signature
*
sig
;
git_signature
*
sig
;
struct
tm
_utc
,
_local
;
struct
tm
_utc
;
*
sig_out
=
NULL
;
*
sig_out
=
NULL
;
/*
* Get the current time as seconds since the epoch and
* transform that into a tm struct containing the time at
* UTC. Give that to mktime which considers it a local time
* (tm_isdst = -1 asks it to take DST into account) and gives
* us that time as seconds since the epoch. The difference
* between its return value and 'now' is our offset to UTC.
*/
time
(
&
now
);
time
(
&
now
);
utc_tm
=
p_gmtime_r
(
&
now
,
&
_utc
);
utc_tm
=
p_gmtime_r
(
&
now
,
&
_utc
);
local_tm
=
p_localtime_r
(
&
now
,
&
_local
);
utc_tm
->
tm_isdst
=
-
1
;
offset
=
difftime
(
now
,
mktime
(
utc_tm
));
offset
=
mktime
(
local_tm
)
-
mktime
(
utc_tm
);
offset
/=
60
;
offset
/=
60
;
/* mktime takes care of setting tm_isdst correctly */
if
(
local_tm
->
tm_isdst
)
offset
+=
60
;
if
(
git_signature_new
(
&
sig
,
name
,
email
,
now
,
(
int
)
offset
)
<
0
)
if
(
git_signature_new
(
&
sig
,
name
,
email
,
now
,
(
int
)
offset
)
<
0
)
return
-
1
;
return
-
1
;
...
...
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