Changing the format for addDatePicker

I’ve got a datePicker prompt setup and working, but I’d like to be able to change the order of the actual picker component, as:

var c = Prompt.create()

c.title = "Due Date";
c.message = "Select date";

c.addDatePicker("dueDate","Due Date", new Date(), {
	"mode": "date"
	});

c.addButton("OK");

if (c.show()){
	draft.setTemplateTag("dDate",c.fieldValues["dueDate"])
	}

In the UK we define dates by Day-Month-Year, but the picker uses Month-Day-Year.

Is there a way to change this?

I know I can reformat after the selection, but it is confusing to have to select dates in a format not familiar.

Thanks

The date picker is a system component. It should appear the same in Drafts as it would in any other app – and should follow your device’s region/localization settings. Is your device (at the OS level) set to use the UK region?

FWIW, I’m in the UK and all set up for UK locale. Your code gives me a day month year picker.

Holy cow!!! How did I go months without realising my Region was set incorrectly on my computer!? (He looks, sheepishly, at his shoes and hopes people will stop laughing at him…)

2 Likes

Honestly I wish I could set just my date picker to work that way system-wide. M/D/Y order is silly.

2 Likes

Is this an action? Seems pretty useful for me, is there any action for this? I mean for the date picker?

It is built in to drafts. On the desktop it appears as:
CleanShot 2022-01-11 at 15.43.10

On iOS it has a calendar selector.

I have included it using a script step:

var c = Prompt.create()

c.title = "Due Date";
c.message = "Select date";

c.addDatePicker("dueDate","Due Date", new Date(), {
	"mode": "date"
	});

c.addButton("OK");

if (c.show()){
	let dDate = new Date(c.fieldValues["dueDate"]).toString("yyyy-MM-dd")
	draft.setTemplateTag("dDate",dDate)
	}

Didn’t get that, how did you invoke that box on the desktop?

You put the code in a script action step and run the action.