Skip to content

Commit

Permalink
[scan] Fix date_released being set to 0 on platforms with musl
Browse files Browse the repository at this point in the history
%F for ISO date format is only glibc. May affect other date parsing.

Closes #1730
  • Loading branch information
ejurgensen committed Mar 21, 2024
1 parent b1a3941 commit 9b12618
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/library/filescanner_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ parse_date(struct media_file_info *mfi, const char *date_string)
if ((*year == 0) && (safe_atou32(date_string, year) == 0))
ret++;

if ( strptime(date_string, "%FT%T%z", &tm) // ISO 8601, %F=%Y-%m-%d, %T=%H:%M:%S
|| strptime(date_string, "%F %T", &tm)
|| strptime(date_string, "%F %H:%M", &tm)
|| strptime(date_string, "%F", &tm)
// musl doesn't support %F, so %Y-%m-%d is used instead
if ( strptime(date_string, "%Y-%m-%dT%T%z", &tm) // ISO 8601, %T=%H:%M:%S
|| strptime(date_string, "%Y-%m-%d %T", &tm)
|| strptime(date_string, "%Y-%m-%d %H:%M", &tm)
|| strptime(date_string, "%Y-%m-%d", &tm)
)
{
*date_released = mktime(&tm);
Expand All @@ -162,7 +163,7 @@ parse_date(struct media_file_info *mfi, const char *date_string)
if ((*date_released == 0) && (*year != 0))
{
snprintf(year_string, sizeof(year_string), "%" PRIu32 "-01-01T12:00:00", *year);
if (strptime(year_string, "%FT%T", &tm))
if (strptime(year_string, "%Y-%m-%dT%T", &tm))
{
*date_released = mktime(&tm);
ret++;
Expand Down

0 comments on commit 9b12618

Please sign in to comment.