Can someone help my change this code. I would like to have the birthday list be set as a variable so I can use it later in a workflow. Also would like to be able to set the number of upcoming birthdays that the script outputs. Thanks
import contacts
from datetime import datetime
import operator
days_list = []
people = contacts.get_all_people()
now = datetime.now()
for p in people:
b = p.birthday
if b:
next_birthday = datetime(now.year, b.month, b.day)
if next_birthday < now:
next_birthday = datetime(now.year + 1, b.month, b.day)
days = (next_birthday - now).days
days_list.append({'name': p.full_name, 'days': days})
if not days_list:
print 'You don\'t have any birthdays in your address book.'
else:
days_list.sort(key=operator.itemgetter('days'))
print 'Upcoming Birthdays'
print '=' * 40
for item in days_list:
print '* %s in %i days' % (item['name'], item['days'])
Discussion started with RV: Forums New Discussion workflow