Action

Insert Selected Date

Posted by @sylumer, Last update 3 months ago - Unlisted

The first step sets the output format based on strftime formatting - see https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/strftime.3.html

The second step has the user choose a date and outputs the formatted date to a custom template tag.

The third step outputs text containing the tag’s content.

Steps

  • defineTemplateTag

    name
    strftime_date_format
    template
    %d/%m/%Y
  • script

    let pDate= Prompt.create() 
    pDate.title = "Select Date"; 
    pDate.addDatePicker("dtSelected","Select Date", new Date(), { "mode": "date" }); 
    pDate.addButton("OK"); 
    if (pDate.show())
    { 
        draft.setTemplateTag("selected_date",strftime(pDate.fieldValues["dtSelected"],draft.processTemplate("[[strftime_date_format]]")));
    }
  • insertText

    template
    [[selected_date]]

Options

  • After Success Default
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.