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
25b2a555
Commit
25b2a555
authored
Aug 19, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1799 from ethomson/gettimeofday
Use time(2) to get the time
parents
eb047446
86967cc5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
61 deletions
+7
-61
src/date.c
+7
-7
src/posix.h
+0
-4
src/win32/posix_w32.c
+0
-50
No files found.
src/date.c
View file @
25b2a555
...
@@ -823,15 +823,13 @@ static void pending_number(struct tm *tm, int *num)
...
@@ -823,15 +823,13 @@ static void pending_number(struct tm *tm, int *num)
}
}
static
git_time_t
approxidate_str
(
const
char
*
date
,
static
git_time_t
approxidate_str
(
const
char
*
date
,
const
struct
timeval
*
tv
,
time_t
time_sec
,
int
*
error_ret
)
int
*
error_ret
)
{
{
int
number
=
0
;
int
number
=
0
;
int
touched
=
0
;
int
touched
=
0
;
struct
tm
tm
=
{
0
},
now
;
struct
tm
tm
=
{
0
},
now
;
time_t
time_sec
;
time_sec
=
tv
->
tv_sec
;
p_localtime_r
(
&
time_sec
,
&
tm
);
p_localtime_r
(
&
time_sec
,
&
tm
);
now
=
tm
;
now
=
tm
;
...
@@ -861,7 +859,7 @@ static git_time_t approxidate_str(const char *date,
...
@@ -861,7 +859,7 @@ static git_time_t approxidate_str(const char *date,
int
git__date_parse
(
git_time_t
*
out
,
const
char
*
date
)
int
git__date_parse
(
git_time_t
*
out
,
const
char
*
date
)
{
{
struct
timeval
tv
;
time_t
time_sec
;
git_time_t
timestamp
;
git_time_t
timestamp
;
int
offset
,
error_ret
=
0
;
int
offset
,
error_ret
=
0
;
...
@@ -870,7 +868,9 @@ int git__date_parse(git_time_t *out, const char *date)
...
@@ -870,7 +868,9 @@ int git__date_parse(git_time_t *out, const char *date)
return
0
;
return
0
;
}
}
p_gettimeofday
(
&
tv
,
NULL
);
if
(
time
(
&
time_sec
)
==
-
1
)
*
out
=
approxidate_str
(
date
,
&
tv
,
&
error_ret
);
return
-
1
;
*
out
=
approxidate_str
(
date
,
time_sec
,
&
error_ret
);
return
error_ret
;
return
error_ret
;
}
}
src/posix.h
View file @
25b2a555
...
@@ -71,16 +71,12 @@ typedef int GIT_SOCKET;
...
@@ -71,16 +71,12 @@ typedef int GIT_SOCKET;
#define p_localtime_r localtime_r
#define p_localtime_r localtime_r
#define p_gmtime_r gmtime_r
#define p_gmtime_r gmtime_r
#define p_gettimeofday gettimeofday
#else
#else
typedef
SOCKET
GIT_SOCKET
;
typedef
SOCKET
GIT_SOCKET
;
struct
timezone
;
extern
struct
tm
*
p_localtime_r
(
const
time_t
*
timer
,
struct
tm
*
result
);
extern
struct
tm
*
p_localtime_r
(
const
time_t
*
timer
,
struct
tm
*
result
);
extern
struct
tm
*
p_gmtime_r
(
const
time_t
*
timer
,
struct
tm
*
result
);
extern
struct
tm
*
p_gmtime_r
(
const
time_t
*
timer
,
struct
tm
*
result
);
extern
int
p_gettimeofday
(
struct
timeval
*
tv
,
struct
timezone
*
tz
);
#endif
#endif
...
...
src/win32/posix_w32.c
View file @
25b2a555
...
@@ -518,56 +518,6 @@ p_gmtime_r (const time_t *timer, struct tm *result)
...
@@ -518,56 +518,6 @@ p_gmtime_r (const time_t *timer, struct tm *result)
return
result
;
return
result
;
}
}
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
#ifndef _TIMEZONE_DEFINED
#define _TIMEZONE_DEFINED
struct
timezone
{
int
tz_minuteswest
;
/* minutes W of Greenwich */
int
tz_dsttime
;
/* type of dst correction */
};
#endif
int
p_gettimeofday
(
struct
timeval
*
tv
,
struct
timezone
*
tz
)
{
FILETIME
ft
;
unsigned
__int64
tmpres
=
0
;
static
int
tzflag
;
if
(
NULL
!=
tv
)
{
GetSystemTimeAsFileTime
(
&
ft
);
tmpres
|=
ft
.
dwHighDateTime
;
tmpres
<<=
32
;
tmpres
|=
ft
.
dwLowDateTime
;
/*converting file time to unix epoch*/
tmpres
/=
10
;
/*convert into microseconds*/
tmpres
-=
DELTA_EPOCH_IN_MICROSECS
;
tv
->
tv_sec
=
(
long
)(
tmpres
/
1000000UL
);
tv
->
tv_usec
=
(
long
)(
tmpres
%
1000000UL
);
}
if
(
NULL
!=
tz
)
{
if
(
!
tzflag
)
{
_tzset
();
tzflag
++
;
}
tz
->
tz_minuteswest
=
_timezone
/
60
;
tz
->
tz_dsttime
=
_daylight
;
}
return
0
;
}
int
p_inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
)
int
p_inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
)
{
{
union
{
union
{
...
...
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