Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 788327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:20:44+00:00 2026-05-14T21:20:44+00:00

A user can set a day alert for a birthday. (We do not care

  • 0

A user can set a day alert for a birthday. (We do not care about the year of birth)
He also picks if he wants to be alerted 0, 1, 2, ou 7 days (Delta) before the D day.
Users have a timezone setting.

I want the server to send the alerts at 8 am on the the D day – deleta +- user timezone

Example:

12 jun, with “alert me 3 days before” will give 9 of Jun.

My idea was to have a trigger_datetime extra field saved on the ‘recurrent event’ object.
Like this a cron Job running every hour on my server will just check for all events matching irs current time hour, day and month and send to the alert.

The problem from a year to the next the trigger_date could change !
If the alert is set on 1st of March, with a one day delay that could be either 28 or 29 of February ..

Maybe i should not use the trigger date trick and use some other kind of scheme.

All plans are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:20:45+00:00Added an answer on May 14, 2026 at 9:20 pm

    Although using plain datetime python module you will be able to implement all you need, a much more powerful python-dateutil extension is available, especially if you need to work with recurring events. The code below should give you an indication of how to achieve your goal:

    from datetime import *
    from dateutil.rrule import rrule, YEARLY
    
    # GLOBAL CONFIG
    td_8am = timedelta(seconds=3600*8)
    td_jobfrequency = timedelta(seconds=3600) # hourly job
    
    
    # USER DATA::
    # birthday: assumed to be retrieved from some data source
    bday = date(1960, 5, 12)
    # reminder delta: number of days before the b-day
    td_delta = timedelta(days=6)
    # difference between the user TZ and the server TZ
    tz_diff = timedelta(seconds=3600*5) # example: +5h
    
    
    # from current time minus the job periodicity and the delta
    sday = date.today()
    # occr will return the first birthday from today on
    occr = rrule(YEARLY, bymonth=bday.month, bymonthday=bday.day, dtstart=sday, count=1)[0]
    
    # adjust: subtract the reminder delta, fixed 8h (8am) and tz difference
    occr -= (td_delta + td_8am + tz_diff)
    
    # send the reminder when the adjusted occurance is within this job time period
    if datetime.now() - td_jobfrequency < occr < datetime.now():
        print occr, '@todo: send the reminder'
    else:
        print occr, 'no reminder'
    

    And I suggest that you do not store the next year reminder date, because the delta may change, or timezone may change, and even birthday itself, so you would need to recompute it. The method above basically computes the reminder date (and time) on the fly.

    One more thing I can suggest is to store for which date (birthday including the year) the last reminder has been sent. So if there is a system downtime you would not miss the reminders but send all that have not been sent. You will need to adapt the code to have this additional check and update.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So the other day, I asked this question about how to combine three complex
I want a to user a DateChooser to allow a user to select a
I'm trying to build a list of functions that can be used for arbitrary
I'm trying to figure out a good solution for sending email notifications based on
I am attempting to grab a date supplied via POST, then generate a list
I have an app that creates and stores a session with a given start
I'm grabbing some data from a database that has a stored date value, and
I have an NSString which has escape characters etc in it. I need to
I am developing an iPhone app and would like to create some sort of
having a bit of a problem with a recent project. The goal here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.