forked from HowardHinnant/date
implement current_zone() for iOS using native API from iOSUtils
This commit is contained in:
committed by
Howard Hinnant
parent
09b78ba92c
commit
6941691de4
@@ -38,6 +38,7 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::string get_tzdata_path();
|
std::string get_tzdata_path();
|
||||||
|
std::string get_current_timezone();
|
||||||
|
|
||||||
} // namespace iOSUtils
|
} // namespace iOSUtils
|
||||||
} // namespace date
|
} // namespace date
|
||||||
|
12
src/tz.cpp
12
src/tz.cpp
@@ -3738,6 +3738,18 @@ tzdb::current_zone() const
|
|||||||
// Fall through to try other means.
|
// Fall through to try other means.
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
// On some versions of some bsd distro's (e.g. iOS),
|
||||||
|
// it is not possible to use file based approach,
|
||||||
|
// we switch to system API, calling functions in
|
||||||
|
// CoreFoundation framework.
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
std::string result = date::iOSUtils::get_current_timezone();
|
||||||
|
if (!result.empty())
|
||||||
|
return locate_zone(result);
|
||||||
|
#endif
|
||||||
|
// Fall through to try other means.
|
||||||
|
}
|
||||||
|
{
|
||||||
// On some versions of some linux distro's (e.g. Red Hat),
|
// On some versions of some linux distro's (e.g. Red Hat),
|
||||||
// the current timezone might be in the first line of
|
// the current timezone might be in the first line of
|
||||||
// the /etc/sysconfig/clock file as:
|
// the /etc/sysconfig/clock file as:
|
||||||
|
Reference in New Issue
Block a user