bool MCSystemPickTime(MCDateTime *p_current, MCDateTime *p_min, MCDateTime *p_max, int32_t p_step, bool p_use_cancel, bool p_use_done, MCDateTime *r_result, bool &r_canceled, MCRectangle p_button_rect) { if (s_in_popup_dialog) return false; int32_t t_hour, t_minute; MCExecPoint ep(nil, nil, nil); MCDateTime t_current; if (p_current != nil) t_current = *p_current; else { ep.setnvalue(MCS_time()); MCD_convert_to_datetime(ep, CF_SECONDS, CF_UNDEFINED, t_current); } // IM-2012-05-09 - make sure we show the correct local hour + minute values MCS_datetimetolocal(t_current); t_hour = t_current.hour; t_minute = t_current.minute; s_in_popup_dialog = true; s_dialog_result = kMCDialogResultUnknown; // IM-2012-10-31 [[ BZ 10483 ]] - make sure we have the timezone bias for the date s_selected_date = t_current; MCAndroidEngineRemoteCall("showTimePicker", "vii", nil, t_hour, t_minute); while (s_in_popup_dialog) MCscreen->wait(60.0, True, True); if (s_dialog_result == kMCDialogResultError) return false; r_canceled = s_dialog_result == kMCDialogResultCanceled; if (!r_canceled) { // IM-2012-10-31 [[ BZ 10483 ]] - convert the return value back to UTC MCS_datetimetouniversal(s_selected_date); *r_result = s_selected_date; } return true; }
void MCPickDoPickDateTime(MCExecContext& ctxt, MCStringRef p_current, MCStringRef p_start, MCStringRef p_end, int32_t *p_step, MCPickButtonType p_buttons, MCRectangle p_button_rect, int p_which) { MCDateTime t_current; MCDateTime *t_current_ptr; t_current_ptr = nil; // PM-2015-09-01: [[ Bug 15844 ]] Allow calling mobilePickDate with empty [, current] [, start] [, end] parameters // i.e. mobilePickDate "time",,,,10 if (!MCStringIsEmpty(p_current)) { if (!MCD_convert_to_datetime(ctxt, p_current, CF_UNDEFINED, CF_UNDEFINED, t_current)) return; t_current_ptr = &t_current; } MCDateTime t_start; MCDateTime *t_start_ptr; t_start_ptr = nil; if (!MCStringIsEmpty(p_start)) { if (!MCD_convert_to_datetime(ctxt, p_start, CF_UNDEFINED, CF_UNDEFINED, t_start)) return; t_start_ptr = &t_start; } MCDateTime t_end; MCDateTime *t_end_ptr; t_end_ptr = nil; if (!MCStringIsEmpty(p_end)) { if (!MCD_convert_to_datetime(ctxt, p_end, CF_UNDEFINED, CF_UNDEFINED, t_end)) return; t_end_ptr = &t_end; } int32_t t_step; if (p_step != nil) t_step = *p_step; else t_step = 1; bool t_cancel_button, t_done_button; t_cancel_button = false; t_done_button = false; switch (p_buttons) { case kMCPickButtonCancel: t_cancel_button = true; break; case kMCPickButtonDone: t_done_button = true; break; case kMCPickButtonCancelAndDone: t_cancel_button = true; t_done_button = true; break; case kMCPickButtonNone: default: break; } MCDateTime t_result; bool t_cancelled; t_cancelled = false; bool t_success; t_success = true; MCAutoValueRef t_result_string; // SN-2014-12-03: [[ Bug 14120 ]] If the picker has been cancelled, we should not try to convert the uninitialised t_result. switch (p_which) { case kMCPickDate: t_success = (MCSystemPickDate(t_current_ptr, t_start_ptr, t_end_ptr, t_cancel_button, t_done_button, &t_result, t_cancelled, p_button_rect) && (t_cancelled || MCD_convert_from_datetime(ctxt, t_result, CF_DATE, CF_UNDEFINED, &t_result_string))); break; case kMCPickTime: t_success = (MCSystemPickTime(t_current_ptr, t_start_ptr, t_end_ptr, t_step, t_cancel_button, t_done_button, &t_result, t_cancelled, p_button_rect) && (t_cancelled || MCD_convert_from_datetime(ctxt, t_result, CF_TIME, CF_UNDEFINED, &t_result_string))); break; case kMCPickDateAndTime: t_success = (MCSystemPickDateAndTime(t_current_ptr, t_start_ptr, t_end_ptr, t_step, t_cancel_button, t_done_button, &t_result, t_cancelled, p_button_rect) && (t_cancelled || MCD_convert_from_datetime(ctxt, t_result, CF_DATE, CF_TIME, &t_result_string))); break; default: MCUnreachable(); } if (t_success) { if (t_cancelled) ctxt.SetTheResultToStaticCString("cancel"); else ctxt . SetTheResultToValue(*t_result_string); return; } ctxt . SetTheResultToEmpty(); }