#include <utils_i18n_private.h>
#include <utils_i18n_ustring.h>
+#include <unistd.h>
#include <unicode/ustdio.h>
#include <unicode/ucal.h>
#include <unicode/timezone.h>
return I18N_ERROR_NONE;
}
+#define TZDEFAULT "/opt/etc/localtime"
+#define TZZONEINFO "/usr/share/zoneinfo/"
+
int i18n_timezone_create_default(i18n_timezone_h *timezone)
{
retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER);
*timezone = TimeZone::createDefault();
+ //Implement fallback mechanism to set the time zone to default time zone
+ char* zoneInfo = NULL;
+ UnicodeString TimezoneID;
+ ((TimeZone *) *timezone)->getID(TimezoneID);
+ const UChar *tid = TimezoneID.getTerminatedBuffer();
+ char tzpath[1024];
+ int32_t ret = (int32_t) readlink(TZDEFAULT, tzpath, sizeof(tzpath) - 1);
+ if(ret > 0)
+ {
+ tzpath[ret] ='\0';
+ int32_t zoneinfolen = strlen(TZZONEINFO);
+ zoneInfo = tzpath + zoneinfolen;
+ }
+ if(tid == NULL) {
+ *timezone = TimeZone::createTimeZone(zoneInfo);
+ return I18N_ERROR_NONE;
+ }
+ int32_t ulen = i18n_ustring_get_length(tid);
+ if(ulen <= 0) {
+ *timezone = TimeZone::createTimeZone(zoneInfo);
+ }
return I18N_ERROR_NONE;
}