Skip to content

Commit

Permalink
Allow caption timestamp to be be an ISO 8601 format string
Browse files Browse the repository at this point in the history
  • Loading branch information
acaudwell committed Feb 3, 2022
1 parent 56b7b30 commit 134a0a6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
@@ -1,6 +1,6 @@
0.52:
* Allow custom log timestamp to be a string.
* Support ISO 8601 timestamp format.
* Allow custom log and caption file timestamps to be strings.
* Change regular expression library to PCRE2.
* Fixed filenames not being affected by --font-scale (Carl Colena).
* Fixed file key not being affected by --font-scale.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -391,7 +391,7 @@ Custom Log Format:
If you want to use Gource with something other than the supported systems,
there is a pipe ('|') delimited custom log format:

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

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

Recording Videos:
Expand Down
2 changes: 1 addition & 1 deletion data/gource.1
Expand Up @@ -370,7 +370,7 @@ colour - A colour for the file in hex (FFFFFF) format. Optional.
Gource can display captions along the timeline by specifying a caption file (using \-\-caption\-file) in the pipe ('|') delimited format below:

.ti 10
timestamp - A unix timestamp of when to display the caption.
timestamp - An ISO 8601 or unix timestamp of when to display the caption.
.ti 10
caption - The caption

Expand Down
15 changes: 13 additions & 2 deletions src/gource.cpp
Expand Up @@ -1062,7 +1062,7 @@ void Gource::seekTo(float percent) {
commitlog->seekTo(percent);
}

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

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

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

time_t timestamp = atol(matches[0].c_str());
time_t timestamp;

// Allow timestamp to be a string
if(matches[0].size() > 1 && matches[0].find("-", 1) != std::string::npos) {
if(!SDLAppSettings::parseDateTime(matches[0], timestamp))
continue;
} else {
timestamp = (time_t) atoll(matches[0].c_str());
if(!timestamp && matches[0] != "0")
continue;
}

std::string caption = RCommitLog::filter_utf8(matches[1]);

//ignore older captions
Expand Down
3 changes: 2 additions & 1 deletion tests/logs/utf8-caption.log
@@ -1 +1,2 @@
1277787465|Árvíztűrő tükörfúrógép removes a file
1277787455|Árvíztűrő tükörfúrógép adds a file
2010-06-29 16:57:45|Árvíztűrő tükörfúrógép removes a file

0 comments on commit 134a0a6

Please sign in to comment.