Jump to content

New Date Calculation in Snippets, Please


Recommended Posts

Although I am relatively new to Alfred's PowerPack, I have been using the heck out of Snippets--especially since I was a TextExpander user.

 

However, it would be great to have more Date calculation capabilities. For example, if I want to write an email that says your response is due next Friday, I would love to have something like {date +Friday} as a way to say replace this with the date for next Friday. 

 

Just a thought.

Link to comment
Share on other sites

This is possible with a snippet workflow. With this example you can set a workflow variable to control the date format 

 

giphy.gif

 

import os
import datetime

env = os.environ
date_format = env.get('date_format', '%Y-%m-%d')

d = datetime.date.today()
while d.weekday() != 4:
    d += datetime.timedelta(1)

print d.strftime(date_format),

 

Edited by Terminal
Link to comment
Share on other sites

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...