#return d.datetime.strftime("%A, %b. %d, %Y at %I:%M %p")

day_names = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
             "Saturday", "Sunday"]

print "Today's scheduled work"
print "----------------------"
print "user\tstart_time\tend_time"

# Iterate each user
for luser in models.Luser.query.all():
   
    # We need to use the time in the user's own timezone, because
    # we are storing naive times in the user's schedule.
    now = Delorean(timezone=luser.profile[0].timezone).datetime
    day = now.weekday()

    mailer = Mailer(**MAILER_PARAMS)

    # Users have multiple schedules. Check all of them.
    for schedule in luser.schedules:

        # Check each day until we hit the day that is today, in the
        # user's timezone.
        for range in schedule.ranges:
            if range.day is not None and range.day.name == day_names[day]:

                # Print out today's users who have hours, as an aid.
                print "%s\t%s\t%s" % (luser.profile[0].username,
                                      range.start_time,
                                      range.end_time)