DaveDay Posted January 10, 2021 Share Posted January 10, 2021 Hi everyone, I'm new to Alfred, and have just purchased the Powerpack. I was wondering if it's possible to create a text snippet which inserts the date of the next Monday. I currently use aText to insert next Monday's date whenever I type mmon. I'm hoping Alfred can replace aText for this action. Many thanks for any help with this. Dave Link to comment
deanishe Posted January 10, 2021 Share Posted January 10, 2021 (edited) Hi @DaveDay, welcome to the forum. I’m afraid Alfred’s native dynamic placeholders can’t do that. You’d have to use a Snippet Trigger with a script to generate the date. This Python script prints the date of the following Monday. Adjust FORMAT to get the date format you want. #!/usr/bin/python3 from __future__ import print_function from datetime import date, timedelta # date format # https://docs.python.org/3.9/library/datetime.html#strftime-strptime-behavior FORMAT = '%Y-%m-%d' one_day = timedelta(days=1) # start counting from tomorrow d = date.today() + one_day while d.weekday(): # Monday = weekday 0 d += one_day print(d.strftime(FORMAT), end='') Edited January 10, 2021 by deanishe Chris Messina 1 Link to comment
DaveDay Posted January 10, 2021 Author Share Posted January 10, 2021 Hi @deanishe Thank you so much! I'm away from my Mac until tomorrow but I’ll try what you said once I’m back. thanks again! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now