diff --git a/src/db.c b/src/db.c index 8fbedf84..ae37ec92 100644 --- a/src/db.c +++ b/src/db.c @@ -187,7 +187,7 @@ static const struct col_type_map mfi_cols_map[] = { "song_length", mfi_offsetof(song_length), DB_TYPE_INT }, { "file_size", mfi_offsetof(file_size), DB_TYPE_INT64 }, { "year", mfi_offsetof(year), DB_TYPE_INT }, - { "date_released", mfi_offsetof(date_released), DB_TYPE_INT }, + { "date_released", mfi_offsetof(date_released), DB_TYPE_INT64 }, { "track", mfi_offsetof(track), DB_TYPE_INT }, { "total_tracks", mfi_offsetof(total_tracks), DB_TYPE_INT }, { "disc", mfi_offsetof(disc), DB_TYPE_INT }, diff --git a/src/db.h b/src/db.h index 75fb3941..70b0ca87 100644 --- a/src/db.h +++ b/src/db.h @@ -190,7 +190,7 @@ struct media_file_info { uint32_t song_length; int64_t file_size; uint32_t year; /* TDRC */ - uint32_t date_released; + int64_t date_released; // bumped to (signed) int64 since all 32bits are unsigned uint32_t track; /* TRCK */ uint32_t total_tracks; diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index e6770c06..56cdb771 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -147,7 +147,7 @@ safe_json_add_time_from_string(json_object *obj, const char *key, const char *va static inline void safe_json_add_date_from_string(json_object *obj, const char *key, const char *value) { - uint32_t tmp; + int64_t tmp; time_t timestamp; struct tm tm; char result[32]; @@ -155,9 +155,9 @@ safe_json_add_date_from_string(json_object *obj, const char *key, const char *va if (!value) return; - if (safe_atou32(value, &tmp) != 0) + if (safe_atoi64(value, &tmp) != 0) { - DPRINTF(E_LOG, L_WEB, "Error converting timestamp to uint32_t: %s\n", value); + DPRINTF(E_LOG, L_WEB, "Error converting timestamp to int64_t: %s\n", value); return; } diff --git a/src/library/filescanner_ffmpeg.c b/src/library/filescanner_ffmpeg.c index e489885e..1f8577d1 100644 --- a/src/library/filescanner_ffmpeg.c +++ b/src/library/filescanner_ffmpeg.c @@ -98,7 +98,8 @@ parse_date(struct media_file_info *mfi, char *date_string) { char year_string[32]; uint32_t *year = (uint32_t *) ((char *) mfi + mfi_offsetof(year)); - uint32_t *date_released = (uint32_t *) ((char *) mfi + mfi_offsetof(date_released)); + // signed in db.h to handle dates before 1970 + int64_t *date_released = (int64_t *) ((char *) mfi + mfi_offsetof(date_released)); struct tm tm = { 0 }; int ret = 0; @@ -111,7 +112,7 @@ parse_date(struct media_file_info *mfi, char *date_string) || strptime(date_string, "%F", &tm) ) { - *date_released = (uint32_t)mktime(&tm); + *date_released = mktime(&tm); ret++; } @@ -120,7 +121,7 @@ parse_date(struct media_file_info *mfi, char *date_string) snprintf(year_string, sizeof(year_string), "%" PRIu32 "-01-01T12:00:00", *year); if (strptime(year_string, "%FT%T", &tm)) { - *date_released = (uint32_t)mktime(&tm); + *date_released = mktime(&tm); ret++; } }