diff --git a/ChangeLog b/ChangeLog index d044da35..0576639f 100644 --- a/ChangeLog +++ b/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. diff --git a/README.md b/README.md index b3246cd0..11fb0fe4 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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: diff --git a/data/gource.1 b/data/gource.1 index 0409135e..f153a718 100644 --- a/data/gource.1 +++ b/data/gource.1 @@ -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 diff --git a/src/gource.cpp b/src/gource.cpp index 586ab502..a30da136 100644 --- a/src/gource.cpp +++ b/src/gource.cpp @@ -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; @@ -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 diff --git a/tests/logs/utf8-caption.log b/tests/logs/utf8-caption.log index 86dbfa60..0f94f494 100644 --- a/tests/logs/utf8-caption.log +++ b/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