mirror of
https://github.com/HowardHinnant/date.git
synced 2024-12-26 07:53:16 +08:00
support Android for current_zone()
This commit is contained in:
parent
706b1286e8
commit
f986299fbb
16
src/tz.cpp
16
src/tz.cpp
@ -92,6 +92,10 @@
|
|||||||
# define TARGET_OS_SIMULATOR 0
|
# define TARGET_OS_SIMULATOR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ANDROID) || defined(__ANDROID__)
|
||||||
|
#include <sys/system_properties.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USE_OS_TZDB
|
#if USE_OS_TZDB
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
@ -4092,6 +4096,18 @@ tzdb::current_zone() const
|
|||||||
if (!result.empty())
|
if (!result.empty())
|
||||||
return locate_zone(result);
|
return locate_zone(result);
|
||||||
#endif
|
#endif
|
||||||
|
// Fall through to try other means.
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// On Android, it is not possible to use file based approach either,
|
||||||
|
// we have to ask the value of `persist.sys.timezone` system property
|
||||||
|
#if defined(ANDROID) || defined(__ANDROID__)
|
||||||
|
char sys_timezone[PROP_VALUE_MAX];
|
||||||
|
if (__system_property_get("persist.sys.timezone", sys_timezone) > 0)
|
||||||
|
{
|
||||||
|
return locate_zone(sys_timezone);
|
||||||
|
}
|
||||||
|
#endif // defined(ANDROID) || defined(__ANDROID__)
|
||||||
// Fall through to try other means.
|
// Fall through to try other means.
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user