Пример #1
0
String
TimeAndPlace::GetReadableTime(void) {

	LocaleManager localeManager;
	localeManager.Construct();
	Locale locale = localeManager.GetSystemLocale();
	TimeZone timeZone = localeManager.GetSystemTimeZone();

	AppLog("GMT Time Zone id is %S", timeZone.GetGmtTimeZone().GetId().GetPointer());
	AppLog("Time Zone is %S", timeZone.GetId().GetPointer());
	AppLog("Time Zone offset is %d", timeZone.GetRawOffset());
	AppLog("Time Zone DST is %d", timeZone.GetDstSavings());

	String customizedPattern = L"HH:mm:ss";
	String readableDateTime;
	DateTimeFormatter* formatter = DateTimeFormatter::CreateDateFormatterN();
	formatter -> ApplyPattern(customizedPattern);

	DateTime standardOffsetDateTime = timeZone.UtcTimeToStandardTime(*dateTime, timeZone.GetRawOffset());
	formatter -> Format(standardOffsetDateTime, readableDateTime);
	AppLog("Standard Local Time is %S", readableDateTime.GetPointer());

	readableDateTime.Append("\n");
	readableDateTime.Append(timeZone.GetId());

	return readableDateTime;
}
Пример #2
0
String
EditEventForm::GetTimezoneString(void) const
{
	LocaleManager localeManager;
	localeManager.Construct();
	TimeZone timeZone = localeManager.GetSystemTimeZone();

	return timeZone.GetId();
}
Пример #3
0
void
TimeAndPlace::SetSiderialTime(float longitude, float latitude, DateTime* currTime) {
	AppLog("Trying to access TimeAndPlace");
	TimeAndPlace::SetLongitude(longitude);
	AppLog("Trying to access TimeAndPlace 1");
	TimeAndPlace::SetLatitude(latitude);
	AppLog("Trying to access TimeAndPlace 2");
	//TimeZone timeZone(60, L"Europe/London");

	LocaleManager localeManager;
	localeManager.Construct();
	Locale locale = localeManager.GetSystemLocale();
	TimeZone timeZone = localeManager.GetSystemTimeZone();

	AppLog("Locale code %S", (locale.GetLanguageCodeString().GetPointer()));
	AppLog("TimeZone ID is %S", (timeZone.GetId()).GetPointer());

//	TimeZone timeZone(TimeZone::GetGmtTimeZone());
	AppLog("TP1");
	SystemTime::GetCurrentTime(*currTime);
	AppLog("TP2");
	dateTime = currTime;
	AppLog("TP2a");
	localDateTime = &(timeZone.UtcTimeToStandardTime(*currTime));
	Calendar* calendar;
	AppLog("TP3");
	calendar = Calendar::CreateInstanceN(timeZone, CALENDAR_GREGORIAN);
	AppLog("TP4");
	calendar->SetTime(*currTime);
	AppLog("TP5");
	float hrs = (calendar->GetTimeField(TIME_FIELD_HOUR_OF_DAY))-1;
	AppLog("TP6");
	float minHrs = calendar->GetTimeField(TIME_FIELD_MINUTE)/60.0;
	AppLog("TP7");
	float dayFract = (hrs + minHrs)/24.0;
	AppLog("TP8");
	float dayNum = calendar->GetTimeField(TIME_FIELD_DAY_OF_YEAR);
	AppLog("TP9");
	float year = calendar->GetTimeField(TIME_FIELD_YEAR);
	AppLog("TP10");
	double daysSinceJ2000 = -1.5 + dayNum + (year-2000)*365 + (int)((year-2000)/4) + dayFract;
	AppLog("TP11");
	double slt = 100.46 + 0.985647 * daysSinceJ2000 + longitude + 15*(hrs + minHrs);
	AppLog("TP12");
	int sltInt = (int)(slt/360);
	AppLog("TP13");
	float sltHrs = (slt-(360*sltInt))/15;
	AppLog("TP14");
	SetSiderialTime (sltHrs);
	AppLog("TP15");
}
Пример #4
0
DateTime*
TimeAndPlace::GetStandardDateTime(void) {

	LocaleManager localeManager;
	localeManager.Construct();
	Locale locale = localeManager.GetSystemLocale();
	TimeZone timeZone = localeManager.GetSystemTimeZone();

	AppLog("GMT Time Zone id is %S", timeZone.GetGmtTimeZone().GetId().GetPointer());
	AppLog("Time Zone is %S", timeZone.GetId().GetPointer());
	AppLog("Time Zone offset is %d", timeZone.GetRawOffset());
	AppLog("Time Zone DST is %d", timeZone.GetDstSavings());

	result r;

	String customizedPattern = L"HH:mm:ss zzz";
	String readableDateTime;
	DateTimeFormatter* formatter = DateTimeFormatter::CreateDateFormatterN();
	r = formatter -> ApplyPattern(customizedPattern);
	AppLog("formatter -> ApplyPattern(customizedPattern) result is %s", GetErrorMessage(r));

	DateTime standardOffsetDateTime = timeZone.UtcTimeToStandardTime(*dateTime, timeZone.GetRawOffset());
	r = formatter -> Format(standardOffsetDateTime, readableDateTime);
	AppLog("Standard Local Time is %S", readableDateTime.GetPointer());
	readableDateTime.Clear();

	DateTime standardDateTime = timeZone.UtcTimeToStandardTime(*dateTime);
	r = formatter -> Format(standardDateTime, readableDateTime);
	AppLog("Standard Time is %S", readableDateTime.GetPointer());
	readableDateTime.Clear();

	DateTime wallDateTime = timeZone.UtcTimeToWallTime(*dateTime);
	r = formatter -> Format(wallDateTime, readableDateTime);
	AppLog("Wall Time is %S", readableDateTime.GetPointer());
	readableDateTime.Clear();

	r = formatter -> Format(*dateTime, readableDateTime);
	AppLog("UTC Time is %S", readableDateTime.GetPointer());
	readableDateTime.Clear();

//	Calendar* calendar = Calendar::CreateInstanceN(timeZone, CALENDAR_GREGORIAN);
//	DateTime localTime1 = calendar -> GetTime();
//	r = formatter -> Format(localTime1, readableDateTime);
//	AppLog("Local Time is %S", readableDateTime.GetPointer());

	return localDateTime;
}
Пример #5
0
result
EditEventForm::UpdateEvent(void)
{
	result r = E_SUCCESS;

	// Sets the Subject
	String strValue = __pSubjectEditField->GetText();
	if (strValue.IsEmpty() == false)
	{
		__pCalEvent->SetSubject(strValue);
	}

	// Sets the Location
	__pCalEvent->SetLocation(__pLocationEditField->GetText());

	// Sets the Description
	__pCalEvent->SetDescription(__pDescriptionEditField->GetText());

	// Sets the Priority
	__pCalEvent->SetPriority(__selectedPriority);

	// Sets the Sensitivity
	__pCalEvent->SetSensitivity(__selectedSensitivity);

	// Sets the Status
	__pCalEvent->SetStatus(__selectedStatus);

	// Gets the Time zone.
	LocaleManager localeManager;
	localeManager.Construct();

	TimeZone timeZone = localeManager.GetSystemTimeZone();
	__pCalEvent->SetTimeZone(timeZone);

	DateTime startDate;
	DateTime endDate;

	__pCalEvent->SetRecurrence(null);

	if (__pIsAllDayButton->IsSelected() == true)
	{
		__pCalEvent->SetAllDayEvent(true);

		startDate = __pStartEditDate->GetDate();
		endDate = __pEndEditDate->GetDate();
		endDate.AddDays(1);

		__pCalEvent->SetStartAndEndTime(startDate, endDate);
	}
	else
	{
		__pCalEvent->SetAllDayEvent(false);
		startDate.SetValue(__pStartEditDate->GetYear(), __pStartEditDate->GetMonth(), __pStartEditDate->GetDay(), __pStartEditTime->GetHour(), __pStartEditTime->GetMinute(), 0);
		endDate.SetValue(__pEndEditDate->GetYear(), __pEndEditDate->GetMonth(), __pEndEditDate->GetDay(), __pEndEditTime->GetHour(), __pEndEditTime->GetMinute(), 0);
		__pCalEvent->SetStartAndEndTime(timeZone.WallTimeToUtcTime(startDate), timeZone.WallTimeToUtcTime(endDate));
	}

	// Sets the Reminder
	const IList& pReminderList = __pCalEvent->GetAllReminders();
	if (pReminderList.GetCount() > 0)
	{
		__pCalEvent->RemoveReminderAt(0);
	}

	strValue = __pReminderEditField->GetText();
	if (strValue.IsEmpty() == false)
	{
		int timeOffset = 0;
		Integer::Parse(strValue, timeOffset);
		if (timeOffset > 0)
		{
			Reminder reminder;
			reminder.SetTimeOffset(__selectedReminder, timeOffset);
			__pCalEvent->AddReminder(reminder);
		}
	}

	// Sets the Recurrence
	if (__pRecurrence != null)
	{
		const DateTime* pUntilDate = __pRecurrence->GetUntil();
		if (pUntilDate && __pCalEvent->IsAllDayEvent() == false)
		{
			DateTime utcTime = timeZone.WallTimeToUtcTime(*pUntilDate);
			__pRecurrence->SetUntil(&utcTime);
		}
		r = __pCalEvent->SetRecurrence(__pRecurrence);
		TryCatch(!IsFailed(r), , "[%s] Failed to set recurrence to event.", GetErrorMessage(r));
	}

	r = __pCalendarbook->UpdateEvent(*__pCalEvent);
	TryCatch(!IsFailed(r), , "[%s] Failed to update the event.", GetErrorMessage(r));

	return r;

CATCH:
	int doModal;
	MessageBox messageBox;
	messageBox.Construct(L"Error", "Failed to edit the event.", MSGBOX_STYLE_OK, 0);
	messageBox.ShowAndWait(doModal);

	return r;
}
Пример #6
0
void
EditEventForm::LoadEvent(void)
{
	result r = E_SUCCESS;

	// Loads the Subject
	__pSubjectEditField->SetText(__pCalEvent->GetSubject());

	// Loads the Time
	DateTime startDate = __pCalEvent->GetStartTime();
	DateTime endDate = __pCalEvent->GetEndTime();

	if (__pCalEvent->IsAllDayEvent() == true)
	{
		__pIsAllDayButton->SetSelected(true);

		// Start Date
		__pStartEditDate->SetDate(startDate);
		__pStartEditTime->SetShowState(false);

		// End Date
		if(startDate < endDate)
		{
			endDate.AddDays(-1);
		}
		__pEndEditDate->SetDate(endDate);
		__pEndEditTime->SetShowState(false);
	}
	else
	{
		// Convert UTC time to local time
		LocaleManager localeManager;
		r = localeManager.Construct();
		TryReturnVoid(!IsFailed(r), "[%s] Failed to construct localeManager.", GetErrorMessage(r));

		TimeZone timeZone = localeManager.GetSystemTimeZone();
		startDate = timeZone.UtcTimeToWallTime(startDate);
		endDate = timeZone.UtcTimeToWallTime(endDate);

		// Start Date
		__pStartEditDate->SetDate(startDate);
		__pStartEditTime->SetTime(startDate);

		// End Date
		__pEndEditDate->SetDate(endDate);
		__pEndEditTime->SetTime(endDate);
	}

	// Loads the Location
	__pLocationEditField->SetText(__pCalEvent->GetLocation());

	// Loads the Priority
	__selectedPriority = __pCalEvent->GetPriority();
	switch (__selectedPriority)
	{
	case EVENT_PRIORITY_LOW:
		__pPriorityContextButton->SetText(L"Low");
		break;

	case EVENT_PRIORITY_NORMAL:
		__pPriorityContextButton->SetText(L"Normal");
		break;

	case EVENT_PRIORITY_HIGH:
		__pPriorityContextButton->SetText(L"High");
		break;

	default:
		break;
	}

	// Loads the Sensitivity
	__selectedSensitivity = __pCalEvent->GetSensitivity();
	switch (__selectedSensitivity)
	{
	case SENSITIVITY_PUBLIC:
		__pSensitivityContextButton->SetText(L"Public");
		break;

	case SENSITIVITY_PRIVATE:
		__pSensitivityContextButton->SetText(L"Private");
		break;

	case SENSITIVITY_CONFIDENTIAL:
		__pSensitivityContextButton->SetText(L"Confidential");
		break;

	default:
		break;
	}

	// Loads the Status
	__selectedStatus = __pCalEvent->GetStatus();
	switch (__selectedStatus)
	{
	case EVENT_STATUS_NONE:
		__pStatusContextButton->SetText(L"None");
		break;

	case EVENT_STATUS_CONFIRMED:
		__pStatusContextButton->SetText(L"Confirmed");
		break;

	case EVENT_STATUS_CANCELLED:
		__pStatusContextButton->SetText(L"Cancelled");
		break;

	case EVENT_STATUS_TENTATIVE:
		__pStatusContextButton->SetText(L"Tentative");
		break;

	default:
		break;
	}

	// Loads the Reminder
	const IList& pReminderList = __pCalEvent->GetAllReminders();
	const Reminder* pReminder = static_cast< const Reminder* >(pReminderList.GetAt(0));

	if (pReminder != null)
	{
		int timeOffset = pReminder->GetTimeOffset();

		switch (pReminder->GetTimeUnit())
		{
		case REMINDER_TIME_UNIT_MINUTE:
			__pReminderContextButton->SetText(L"minutes(s)");
			break;

		case REMINDER_TIME_UNIT_HOUR:
			__pReminderContextButton->SetText(L"hour(s)");
			break;

		case REMINDER_TIME_UNIT_DAY:
			__pReminderContextButton->SetText(L"day(s)");
			break;

		case REMINDER_TIME_UNIT_WEEK:
			__pReminderContextButton->SetText(L"week(s)");
			break;
		case REMINDER_TIME_UNIT_NONE:
		default:
			break;
		}

		__pReminderEditField->SetText(Integer::ToString(timeOffset));
	}

	// Loads the Recurrence
	const Recurrence* pRecurrence = __pCalEvent->GetRecurrence();
	String RecurrenceValue;

	if (pRecurrence != null)
	{
		__pRecurrence = new (std::nothrow) Recurrence(*pRecurrence);
	}
	else
	{
		__pRecurrence = null;
	}

	__pSetRecurrenceButton->SetText(GetRecurrenceString());

	// Loads the Description
	__pDescriptionEditField->SetText(__pCalEvent->GetDescription());

}
Пример #7
0
result
EventListForm::OnInitializing(void)
{
	result r = E_SUCCESS;

	Header* pHeader = GetHeader();
	AppAssert(pHeader);

	DateTime today;
	String formattedString;

	SystemTime::GetCurrentTime(WALL_TIME, today);

	__pLocaleCalendar = Tizen::Locales::Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
	__pLocaleCalendar->SetTime(today);
	DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(DATE_TIME_STYLE_DEFAULT);

	String customizedPattern = L"dd MMM yyyy";
	pDateFormatter->ApplyPattern(customizedPattern);
	pDateFormatter->Format(*__pLocaleCalendar, formattedString);

	HeaderItem headerDaily;
	headerDaily.Construct(ID_HEADER_DAILY);
	headerDaily.SetText(L"일");

	HeaderItem headerMonthly;
	headerMonthly.Construct(ID_HEADER_MONTHLY);
	headerMonthly.SetText(L"월");

	pHeader->SetStyle(HEADER_STYLE_SEGMENTED_WITH_TITLE);
	pHeader->SetTitleText(formattedString);
	pHeader->AddItem(headerDaily);
	pHeader->AddItem(headerMonthly);
	pHeader->AddActionEventListener(*this);

	Footer* pFooter = GetFooter();
	AppAssert(pFooter);
	pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);

	FooterItem footerCreate;
	footerCreate.Construct(ID_FOOTER_CREATE);
	footerCreate.SetText(L"일정 생성");
	pFooter->AddItem(footerCreate);

	SetFormBackEventListener(this);
	pFooter->AddActionEventListener(*this);

	Tizen::Ui::Controls::Button* pPreviousButton = new (std::nothrow) Button();
	pPreviousButton->Construct(Rectangle(0, 0, GetClientAreaBounds().width / 2, 72), L"이전");
	pPreviousButton->SetActionId(ID_BUTTON_PREV);
	pPreviousButton->AddActionEventListener(*this);
	AddControl(pPreviousButton);

	Tizen::Ui::Controls::Button* pNextButton = new (std::nothrow) Button();
	pNextButton->Construct(Rectangle(GetClientAreaBounds().width / 2, 0, GetClientAreaBounds().width / 2, 72), L"다음");
	pNextButton->SetActionId(ID_BUTTON_NEXT);
	pNextButton->AddActionEventListener(*this);
	AddControl(pNextButton);

	__pGroupedListView = new (std::nothrow) GroupedListView();
	__pGroupedListView->Construct(Rectangle(0, 72, GetClientAreaBounds().width, GetClientAreaBounds().height - 72), GROUPED_LIST_VIEW_STYLE_INDEXED, true, SCROLL_STYLE_FADE_OUT);
	__pGroupedListView->SetTextOfEmptyList(L"일정 없음");
	__pGroupedListView->SetItemProvider(*this);
	__pGroupedListView->AddGroupedListViewItemEventListener(*this);
	__pGroupedListView->SetItemDividerColor(Tizen::Graphics::Color::GetColor(COLOR_ID_BLACK));
	AddControl(__pGroupedListView);

	LocaleManager localeManager;
	localeManager.Construct();
	__timeZone = localeManager.GetSystemTimeZone();

	return r;
}