date
date copied to clipboard
current_zone() not working on Android
Specifically a Samsung Galaxy Tab running Android 10.
It drops threw to the bottom of the function and throws an exception. I've verified the locations this function searches for aren't present on the device.
So far I've only found a Java API for accessing this information, so if you wanted to add Android support there would need to be some JNI shenanigans undertaken.
Thanks for the report.
current_zone()
is the most non-portable function in this library. I don't have a Samsung Galaxy Tab to experiment with.
I'm 80% sure that there is somewhere on disk this information exists. JNI has to get it from somewhere. If you can find it, I'd be glad to accept a patch, or create one myself to have you test.
So I've located the tzdata data, which is in /system/usr/share/zoneinfo.
But after some more web trawling, I found only that I can retrieve the timezone using the following command from a terminal in Android Studio:
% adb shell getprop persist.sys.timezone Europe/London
Where this comes from....who knows, as there appears to be no folders related to clocks or anything other locations mentioned on the web for different Linux distros.
For me, I've already done the JNI dance for some other stuff, so it's not a big deal to get the string returned by the Java call
TimeZone.getDefault().getID()
Can std::system
be used to execute adb shell getprop persist.sys.timezone
from C++?
Or perhaps do a global search of files that contain "Europe/London"?
Perhaps helpful: https://stackoverflow.com/a/48442083/576911
In other words, they've taken their own custom approach.
Not too sure where this /data/property folder is, can't see that one on my device.