Jump to content

Next Monday?


Recommended Posts

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 post

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 by deanishe
Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...