This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: This workflow prompts the user to select a date, then inserts a taskpaper @start(YYYY-MM-DD) tag at the cursor where YYYY-MM-DD is the selected date.

Copyright (c) 2017 Duncan MacIntyre

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.

# Insert @start tag# A workflow for the iOS text editor Editorial# Copyright (c) 2017 Duncan MacIntyre# This workflow, when run, prompts the user to select a date. @start(YYYY-MM-DD) is then inserted# at the cursor, where YYYY-MM-DD is the selected date.importdatetimeimportdialogsimportworkflowimporteditor# generate a list of DateObjects for the next seven days after todaydates=[datetime.date.today()+datetime.timedelta(days=(i+1))foriinrange(7)]# generate a list of readable dates in the form ' Weekday, Month Day', each corresponding to# one date in datesreadable_dates=[i.strftime(' %A, %B %d')foriindates]# prompt the user to choose one of readable_dates or ' Other', store choice in chosenchosen=dialogs.list_dialog(title='Choose a start date:',items=readable_dates+[' Other'])# if one of readable_dates was chosen...ifchoseninreadable_dates:# change chosen to the DateObject in dates at the same index as chosen is in readable_dateschosen=dates[readable_dates.index(chosen)]# otherwise, if ' Other' was chosen...elifchosen==' Other':# prompt the user to choose a date, store their choice as a DateObject in chosenchosen=dialogs.date_dialog()# if chosen is not None...# (this would happen if the user closed one of the above dialogs without choosing anything)ifchosenisnotNone:# insert @start(YYYY-MM-DD) at the cursor, where YYYY-MM-DD is the chosen date in this formateditor.insert_text('@start('+chosen.isoformat()+')')