Skip to content

Commit 134a0a6

Browse files
committed
Allow caption timestamp to be be an ISO 8601 format string
1 parent 56b7b30 commit 134a0a6

5 files changed

Lines changed: 19 additions & 7 deletions

File tree

‎ChangeLog‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
0.52:
2-
* Allow custom log timestamp to be a string.
32
* Support ISO 8601 timestamp format.
3+
* Allow custom log and caption file timestamps to be strings.
44
* Change regular expression library to PCRE2.
55
* Fixed filenames not being affected by --font-scale (Carl Colena).
66
* Fixed file key not being affected by --font-scale.

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ Custom Log Format:
391391
If you want to use Gource with something other than the supported systems,
392392
there is a pipe ('|') delimited custom log format:
393393

394-
timestamp - An ISO 8601 or unix timestamp of when the update occured.
394+
timestamp - An ISO 8601 or unix timestamp of when the update occurred.
395395
username - The name of the user who made the update.
396396
type - initial for the update type - (A)dded, (M)odified or (D)eleted.
397397
file - Path of the file updated.
@@ -402,7 +402,7 @@ Caption Log Format:
402402
Gource can display captions along the timeline by specifying a caption file
403403
(using --caption-file) in the pipe ('|') delimited format below:
404404

405-
timestamp - A unix timestamp of when to display the caption.
405+
timestamp - An ISO 8601 or A unix timestamp of when to display the caption.
406406
caption - The caption
407407

408408
Recording Videos:

‎data/gource.1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ colour - A colour for the file in hex (FFFFFF) format. Optional.
370370
Gource can display captions along the timeline by specifying a caption file (using \-\-caption\-file) in the pipe ('|') delimited format below:
371371

372372
.ti 10
373-
timestamp - A unix timestamp of when to display the caption.
373+
timestamp - An ISO 8601 or unix timestamp of when to display the caption.
374374
.ti 10
375375
caption - The caption
376376

‎src/gource.cpp‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ void Gource::seekTo(float percent) {
10621062
commitlog->seekTo(percent);
10631063
}
10641064

1065-
Regex caption_regex("^(?:\\xEF\\xBB\\xBF)?([0-9]+)\\|(.+)$");
1065+
Regex caption_regex("^(?:\\xEF\\xBB\\xBF)?([^|]+)\\|(.+)$");
10661066

10671067
void Gource::loadCaptions() {
10681068
if(!gGourceSettings.caption_file.size()) return;
@@ -1082,7 +1082,18 @@ void Gource::loadCaptions() {
10821082

10831083
if(!caption_regex.match(line, &matches)) continue;
10841084

1085-
time_t timestamp = atol(matches[0].c_str());
1085+
time_t timestamp;
1086+
1087+
// Allow timestamp to be a string
1088+
if(matches[0].size() > 1 && matches[0].find("-", 1) != std::string::npos) {
1089+
if(!SDLAppSettings::parseDateTime(matches[0], timestamp))
1090+
continue;
1091+
} else {
1092+
timestamp = (time_t) atoll(matches[0].c_str());
1093+
if(!timestamp && matches[0] != "0")
1094+
continue;
1095+
}
1096+
10861097
std::string caption = RCommitLog::filter_utf8(matches[1]);
10871098

10881099
//ignore older captions

‎tests/logs/utf8-caption.log‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
1277787465|Árvíztűrő tükörfúrógép removes a file
1+
1277787455|Árvíztűrő tükörfúrógép adds a file
2+
2010-06-29 16:57:45|Árvíztűrő tükörfúrógép removes a file

0 commit comments

Comments
 (0)