mirror of
https://github.com/owntone/owntone-server.git
synced 2025-10-29 07:45:04 -04:00
[scan] Use plist_get_unix_date_val() if available
plist_get_date_val is deprecated
This commit is contained in:
parent
d8485bf3c2
commit
d051d787ba
@ -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])
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user