How to subtract the date and time with multiple-choice values

advertisements

I am thinking of a way of calculating the date by subtracting values in multiple choice filed with current date

I have a model which has multiple choices with values that I want to subtract with datetime.datetime.now but I am not sure how it should be done.

REMINDER_CHOICES = (
    (5,'5 minutes before'),
    (15, '15 minutes before'),
    (30, '30 minutes before'),
    (60, '1 hour before'),
    (120, '2 hours before'),
    (240, '4 hours before'),
    (1440, '1 day before'),
)


Just substract a timedelta like this:

date_b = date_a - datetime.timedelta(minutes=30)

or

date_b = date_a - datetime.timedelta(days=2, minutes=30)