[scan] Use plist_get_unix_date_val() if available

plist_get_date_val is deprecated
This commit is contained in:
ejurgensen 2025-08-24 23:14:44 +02:00
parent d8485bf3c2
commit d051d787ba
2 changed files with 14 additions and 2 deletions

View File

@ -195,6 +195,9 @@ PKG_CHECK_EXISTS([libplist],
[OWNTONE_MODULES_CHECK([OWNTONE], [LIBPLIST], [libplist-2.0],
[plist_dict_get_item], [plist/plist.h])])
dnl AC_SEARCH_LIBS does not find plist_get_unix_date_val() on MacOS
OWNTONE_CHECK_DECLS([plist_get_unix_date_val], [plist/plist.h])
AM_PATH_LIBGCRYPT([1:1.7.0])
OWNTONE_FUNC_REQUIRE([OWNTONE], [GNU Crypt Library], [LIBGCRYPT], [gcrypt],
[gcry_control], [gcrypt.h])

View File

@ -219,8 +219,6 @@ static int
get_dictval_date_from_key(plist_t dict, const char *key, uint32_t *val)
{
plist_t node;
int32_t secs;
int32_t dummy;
node = plist_dict_get_item(dict, key);
@ -230,11 +228,22 @@ get_dictval_date_from_key(plist_t dict, const char *key, uint32_t *val)
if (plist_get_node_type(node) != PLIST_DATE)
return -1;
#if HAVE_DECL_PLIST_GET_UNIX_DATE_VAL
int64_t secs;
plist_get_unix_date_val(node, &secs);
*val = (uint32_t) secs;
#else
int32_t secs;
int32_t dummy;
// secs will be number of seconds since 01/01/2001
plist_get_date_val(node, &secs, &dummy);
// make it a Unix Timestamp by adding seconds from 1/1/1970 to 1/1/2001
*val = (uint32_t) (secs + 978307200);
#endif
return 0;
}