1.1.4 • Published 6 years ago

skwas-cordova-plugin-datetimepicker-asb v1.1.4

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

ASB Fork - do not use!

npm version

skwas-cordova-plugin-datetimepicker

Cordova Plugin for showing a native date, time or datetime picker.

Installation

cordova plugin add skwas-cordova-plugin-datetimepicker

or for latest

cordova plugin add https://github.com/skwasjer/skwas-cordova-plugin-datetimepicker.git

Supported platforms

  • Android 4 and higher
  • iOS 8 and higher (tested with Xcode 7.2.3, Xcode 8 and Xcode 9.2)

Methods

show

show(options)
Show the plugin with specified options.

show(options, successCallback, errorCallback)
Show the plugin with specified options and callbacks.

This was the original way to call the plugin, and is kept for compatibility.

Note: The successCallback and errorCallback respectively will be ignored if the success or error callback is provided on the options argument.

Options

NameTypeDefaultAndroidiOS
modeStringdatedate, time, datetimedate, time, datetimeThe display mode
dateDaterequiredrequiredThe initial date to display
allowOldDatesbooleantrue-supportedAllow older dates to be selected
allowFutureDatesbooleantrue-supportedAllow future dates to be selected
minDateDatesupportedsupportedSet the minimum date that can be selected
maxDateDatesupportedsupportedSet the maximum date that can be selected
minuteIntervalint1>= HoneycombsupportedFor minute spinner the number of minutes per step
localeString"EN"-supportedThe locale to use for text and date/time
okTextString"Select"supportedsupportedThe text to use for the ok button
cancelTextString"Cancel"supportedsupportedThe text to use for the cancel button
successFunction-supportedsupportedThe success callback
cancelFunction-supportedsupportedThe cancel callback
errorFunction-supportedsupportedThe error callback
androidObject{}optionalignoredAndroid specific options

Android options

NameTypeDefaultDescription
themeintTheme_DeviceDefault_Dialogandroid.R.style theme
calendar (obsolete)booleanfalsefalse shows spinners, however this depend on the theme selected and SDK version. When true, forces a calendar view.
is24HourViewbooleantrueUse a 24 hour clock

On Lollipop and upwards the date and time pickers changed to calendar and radial pickers. If you want to use spinners (for example to use minuteInterval), use a built-in android.R.style theme that shows a date and time picker with spinners or read up here how to customize this.

Example

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {

	var myDate = new Date(); // From model.

	cordova.plugins.DateTimePicker.show({
		mode: "date",
		date: myDate,
		allowOldDates: true,
		allowFutureDates: true,
		minDate: new Date(),
		maxDate: null,
		minuteInterval: 15,
		locale: "EN",
		okText: "Select",
		cancelText: "Cancel",
		android: {
			theme: 16974126, // Theme_DeviceDefault_Dialog
			calendar: false,
			is24HourView: true
		},
		success: function(newDate) {
			// Handle new date.
			console.info(newDate);
			myDate = newDate;
		},
		cancel: function() {
			console.info("Cancelled");
		},
		error: function (err) {
			// Handle error.
			console.error(err);
		}
	});
}

Note that not all options have to be set.

Changelog

For a list of all changes see here.

Contributors