Google カレンダーだと思いますが、ユーザーに送信するリマインダーのリストを含むテーブルがあります。私のユーザーは世界中にいるので、EST の午前 5 時に全員にメールを送信することはできません。1 時間ごとに実行される cronjob があります。レコードが入力した日付と午前 5 時に一致する場合は、ユーザーにメールを送信します。私はまだその SQL 部分を理解していませんが、それは簡単なはずです (と思います)。今のところ、静的変数を使用して機能をテストしています。
私の問題は、スクリプトが 1 分以内に完了するようにしたいことだと思います。これを行うためのより良い方法が必要です。
from datetime import datetime
from pytz import timezone
d_format = "%Y-%m-%d %H:%M"
# This is the value pulled from the database. Format: (Y-m-d 05:00)
record_date = "2013-07-01 05:00"
# Current time in UTC
servertime = datetime.now(timezone('UTC'))
# Let's assume the user lives on the West Coast
user1 = now_utc.astimezone(timezone('US/Pacific'))
if user1.strftime(d_format) == record_date:
print "Send user an email!"
print ""
# Let's assume the user lives in Singapore
user2 = now_utc.astimezone(timezone('Singapore'))
if user2.strftime(d_format) == record_date:
print "Send user an email!"
print ""