#include <algorithm>
#include <string>
#include <sstream>
+#include <system_settings.h>
#include "Model/WorldClock.h"
#include "Model/Location.h"
#include "Utils/Log.h"
+#include "Utils/Time.h"
using namespace model;
WorldClock::WorldClock()
{
+ char *tz;
+ int current_tz = 11; //GMT+0
+
parameter_signals_.resize((int)ParameterSignalType::MAX);
signals_.resize((int)SignalType::MAX);
LoadItemsList();
- int current_tz = 1;
int ret = preference_get_int("WORLD_CLOCK_MAP_CURRENT_TIMEZONE", ¤t_tz);
if (ret != PREFERENCE_ERROR_NONE) {
- preference_set_int("WORLD_CLOCK_MAP_CURRENT_TIMEZONE", 12); // This timezone 'no' need to be retrieved using current position
- }
- SetCurrentTimezone(&time_zones_.at(current_tz));
+ ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &tz);
+ if (ret == SYSTEM_SETTINGS_ERROR_NONE) {
+ int offset = utils::Time::GetTimezoneOffset(tz);
+ SetCurrentTimezone(GetTimezoneByOffset(offset));
+ DBG("Current timezone set to:%s", tz);
+ }
+ else
+ SetCurrentTimezone(&time_zones_.at(current_tz));
+ } else
+ SetCurrentTimezone(&time_zones_.at(current_tz));
}
WorldClock::~WorldClock()
int ret = preference_set_int("WORLD_CLOCK_MAP_CURRENT_TIMEZONE", GetCurrentTimezoneNo());
if (ret != PREFERENCE_ERROR_NONE) {
- DBG("preference_set_int failed[%d]: %s", ret, get_error_message(ret));
+ ERR("preference_set_int failed[%d]: %s", ret, get_error_message(ret));
}
}