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
8e14b47f
Commit
8e14b47f
authored
Apr 10, 2014
by
Jacques Germishuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce git__date_rfc2822_fmt. Allows for RFC2822 date headers
parent
b3b36a68
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
src/date.c
+28
-0
src/util.h
+12
-0
No files found.
src/date.c
View file @
8e14b47f
...
...
@@ -874,3 +874,31 @@ int git__date_parse(git_time_t *out, const char *date)
*
out
=
approxidate_str
(
date
,
time_sec
,
&
error_ret
);
return
error_ret
;
}
int
git__date_rfc2822_fmt
(
char
*
out
,
size_t
len
,
const
git_time
*
date
)
{
int
written
;
struct
tm
gmt
;
time_t
t
;
assert
(
out
&&
date
);
t
=
(
time_t
)
(
date
->
time
+
date
->
offset
*
60
);
if
(
p_gmtime_r
(
&
t
,
&
gmt
)
==
NULL
)
return
-
1
;
written
=
p_snprintf
(
out
,
len
,
"%.3s, %u %.3s %.4u %02u:%02u:%02u %+03d%02d"
,
weekday_names
[
gmt
.
tm_wday
],
gmt
.
tm_mday
,
month_names
[
gmt
.
tm_mon
],
gmt
.
tm_year
+
1900
,
gmt
.
tm_hour
,
gmt
.
tm_min
,
gmt
.
tm_sec
,
date
->
offset
/
60
,
date
->
offset
%
60
);
if
(
written
<
0
||
(
written
>
(
int
)
len
-
1
))
return
-
1
;
return
0
;
}
src/util.h
View file @
8e14b47f
...
...
@@ -20,6 +20,8 @@
# define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#define GIT_DATE_RFC2822_SZ 32
/*
* Custom memory allocation wrappers
* that set error code and error message
...
...
@@ -329,6 +331,16 @@ extern int git__parse_bool(int *out, const char *value);
extern
int
git__date_parse
(
git_time_t
*
out
,
const
char
*
date
);
/*
* Format a git_time as a RFC2822 string
*
* @param out buffer to store formatted date; a '\\0' terminator will automatically be added.
* @param len size of the buffer; should be atleast `GIT_DATE_RFC2822_SZ` in size;
* @param date the date to be formatted
* @return 0 if successful; -1 on error
*/
extern
int
git__date_rfc2822_fmt
(
char
*
out
,
size_t
len
,
const
git_time
*
date
);
/*
* Unescapes a string in-place.
*
* Edge cases behavior:
...
...
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