Skip to content

Commit c8d746c

Browse files
committed
Changing datetime storage format. Minor fixes.
1 parent 5d38986 commit c8d746c

File tree

2 files changed

+25
-53
lines changed

2 files changed

+25
-53
lines changed

git-info.sty

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
\newcommand\githeadminute{0}
1616
\newcommand\githeadsecond{0}
1717
\newcommand\githeadtzsign{+}
18-
\newcommand\githeadtzhour{00}
19-
\newcommand\githeadtzminute{00}
18+
\newcommand\githeadtzhour{0}
19+
\newcommand\githeadtzminute{0}
2020

2121
% semi-private settings
2222
\newcommand\GI@max@depth{8}
@@ -95,19 +95,11 @@
9595
\GI@get@head@infos
9696
\GI@get@gen@datetime{head}%
9797
\edef\@tempa{\endgroup
98-
\GI@set@export\githeadauthor{\githeadauthor}%
99-
\GI@set@export\githeadmail{\githeadmail}%
10098
\GI@set@export\githeadcommit{\githeadcommit}%
10199
\GI@set@export\githeadbranch{\githeadbranch}%
102-
\GI@set@export\githeadyear{\githeadyear}%
103-
\GI@set@export\githeadmonth{\githeadmonth}%
104-
\GI@set@export\githeadday{\githeadday}%
105-
\GI@set@export\githeadhour{\githeadhour}%
106-
\GI@set@export\githeadminute{\githeadminute}%
107-
\GI@set@export\githeadsecond{\githeadsecond}%
108-
\GI@set@export\githeadtzsign{\githeadtzsign}%
109-
\GI@set@export\githeadtzhour{\githeadtzhour}%
110-
\GI@set@export\githeadtzminute{\githeadtzminute}}%
100+
\GI@set@export\githeadauthor{\githeadauthor}%
101+
\GI@set@export\githeadmail{\githeadmail}%
102+
\GI@set@export\githeaddatetime{\githeaddatetime}}%
111103
\@tempa}
112104

113105
% finding the path to head
@@ -240,41 +232,21 @@
240232
\GI@extract@units\GI@hour{24}%
241233
\GI@extract@year
242234
\GI@extract@month@day
235+
\edef\GI@datetime{%
236+
\GI@year-\GI@two@d{\the\GI@month}-\GI@two@d\GI@day
237+
T\GI@two@d\GI@hour:\GI@two@d\GI@min:\GI@two@d\GI@sec
238+
\GI@tzsign\GI@two@d\GI@tzhour\GI@two@d\GI@tzmin}%
243239
\edef\@tempa{\endgroup
244-
\GI@set@export@name{git#1year}{\GI@year}%
245-
\GI@set@export@name{git#1month}{\the\GI@month}%
246-
\GI@set@export@name{git#1day}{\GI@day}%
247-
\GI@set@export@name{git#1hour}{\GI@hour}%
248-
\GI@set@export@name{git#1minute}{\GI@min}%
249-
\GI@set@export@name{git#1second}{\GI@sec}%
250-
\GI@set@export@name{git#1tzsign}{\GI@tzsign}%
251-
\GI@set@export@name{git#1tzhour}{\GI@tzhour}%
252-
\GI@set@export@name{git#1tzminute}{\GI@tzmin}}%
240+
\GI@set@export@name{git#1datetime}{\GI@datetime}}
253241
\@tempa}
254242

255243
\newcommand\GI@parse@timezone[5]{%
256244
\def\GI@tzsign{#1}%
257245
\def\GI@tzhour{#2#3}%
258246
\def\GI@tzmin{#4#5}}
259247

260-
% time display
261-
262-
\newcommand\GI@pad[1]{%
263-
\ifnum#1<10 0#1\else#1\fi}
264-
265-
\newcommand\githeadisodate{%
266-
\git@gen@isodate{head}}
267-
268-
\newcommand\git@gen@isodate[1]{%
269-
\csname git#1year\endcsname-%
270-
\GI@pad{\csname git#1month\endcsname}-%
271-
\GI@pad{\csname git#1day\endcsname}T%
272-
\GI@pad{\csname git#1hour\endcsname}:%
273-
\GI@pad{\csname git#1minute\endcsname}:%
274-
\GI@pad{\csname git#1second\endcsname}%
275-
\csname git#1tzsign\endcsname
276-
\csname git#1tzhour\endcsname:%
277-
\csname git#1tzminute\endcsname}
248+
\newcommand\GI@two@d[1]{%
249+
\ifnum#1<10 0\number#1\else \number#1\fi}
278250

279251
% main
280252

test-git-info.tex

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@
1010
\def\GI@head@timestamp{#2}%
1111
\def\GI@head@timezone{#1}%
1212
\GI@get@gen@datetime{head}%
13-
\message{^^J#2#1:^^JMacro: \githeadisodate}%
13+
\message{^^J#2#1:^^JMacro: \githeaddatetime}%
1414
\message{^^JReal: \space#3}%
1515
\endgroup}
1616
\makeatother
1717

18-
\testdate{0}{1970-01-01T00:00:00+00:00}
19-
\testdate{2865906}{1970-02-03T04:05:06+00:00}
20-
\testdate{31535999}{1970-12-31T23:59:59+00:00}
21-
\testdate{31536000}{1971-01-01T00:00:00+00:00}
22-
\testdate{951955200}{2000-03-02T00:00:00+00:00}
23-
\testdate{951868799}{2000-02-29T23:59:59+00:00}
24-
\testdate{951868800}{2000-03-01T00:00:00+00:00}
25-
\testdate{978307199}{2000-12-31T23:59:59+00:00}
26-
\testdate{978307200}{2001-01-01T00:00:00+00:00}
27-
\testdate{983404799}{2001-02-28T23:59:59+00:00}
28-
\testdate{983404800}{2001-03-01T00:00:00+00:00}
18+
% \testdate{0}{1970-01-01T00:00:00+00:00}
19+
% \testdate{2865906}{1970-02-03T04:05:06+00:00}
20+
% \testdate{31535999}{1970-12-31T23:59:59+00:00}
21+
% \testdate{31536000}{1971-01-01T00:00:00+00:00}
22+
% \testdate{951955200}{2000-03-02T00:00:00+00:00}
23+
% \testdate{951868799}{2000-02-29T23:59:59+00:00}
24+
% \testdate{951868800}{2000-03-01T00:00:00+00:00}
25+
% \testdate{978307199}{2000-12-31T23:59:59+00:00}
26+
% \testdate{978307200}{2001-01-01T00:00:00+00:00}
27+
% \testdate{983404799}{2001-02-28T23:59:59+00:00}
28+
% \testdate{983404800}{2001-03-01T00:00:00+00:00}
2929

3030
\newcommand\showval[2]{%
3131
\message{^^J#2: -=|#1|=-^^J}}
3232

3333
\showval\githeadcommit{Git commit}
34-
\showval\githeadisodate{Git date (iso)}
34+
\showval\githeaddatetime{Git datetime}
3535
\showval\githeadbranch{Git branch}
3636
\showval\githeadauthor{Git author}
3737
\showval\githeadmail{Git mail}

0 commit comments

Comments
 (0)