6 ms·
Scheduling morning emails with Python and Celery
- deleted 14y ago[deleted]
- est 14y agoalternatively: use uWSGI cron http://uwsgi-docs.readthedocs.org/en/latest/PythonDecorators.html#uwsgidecorators.cron http://uwsgi-docs.readthedocs.org/en/latest/PythonDecorators...
- aqeel 14y agoGood one! People relying on Cron could benefit from this.
- ieze 14y agoThis doesn't handle daylight saving time.
- aqeel 14y agoIt does take care of DST: http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp
- ericcholis 14y agoBetter Reference (W3 Schools sucks: http://w3fools.com/ http://w3fools.com/): https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset https://developer.mozilla.org/en-US/docs/JavaScript/Referenc...
- cyriacthomas 14y agoWouldn't it be a better idea to store the timezone and then account for the DST at the server side? https://bitbucket.org/pellepim/jstimezonedetect https://bitbucket.org/pellepim/jstimezonedetect getTimezoneOffset() gives you the offset with the DST accounted and will be a different time when DST is off.
- aqeel 14y agoWhen it comes to scheduling emails, what we want is user's to get emails at a specific time as exactly as possible. For this all we need is the UTC timezone offset including DST, which javascript gives us. The jstimezonedetect script is a good one if we wan't to know the real timezone. Problem here is we wouldn't know how often this script could remain updated. Any change in DST will have to be provided by the script which if it doesn't there will be in-accuracies. Not to mention the trouble of keeping the script updated. But in general, the script is indeed awesome.
- nsr 14y agoI believe that the point is: If you have the user's timezone, you can /know/ if they are in DST through modules such as pytz+datetime.
- th 14y agoWould this create a problem around Daylight Saving Time until the user logs in again to reset their time offset?
- aqeel 14y agogetTimezoneOffset() would return the value after taking care of DST. So there shouldn't be any DST related inconsistencies. Now if the user moves to another timezone, and never hits one of our page, there is no direct way of tracking his/her change in location.
- th 14y agoI mean that starting mid-March a user who had previously been in a -8:00 UTC offset would then be in a -7:00 UTC offset and you wouldn't know the timezone offset changed until they visited the website again.
- Cherian 14y agoThat’s certainly a problem. But this solution is better than being totally off. Worst case the person gets the mail in the previous timezone he registered which should be before the DST.
- manish_gill 14y agoIsn't the ScheduleTime class doing redundant work? Why bother keeping a dictionary, dealing with ints and strings when you can directly use strftime/strptime? Except for the friday/fri thing, which, to be honest, I don't see the point of. I'd rather have uniformity in my code.
- aqeel 14y agoAgree. Its not the most useful class.
- clicks 14y agoWhile we're on the topic -- there's also http://mailchimp.com/ http://mailchimp.com/ if you want to outsource the job of sending subscription e-mail.
- yeison 14y agoDid anyone else read this title as: 'Scheduling morning meals with Python and Celery'?
- aqeel 14y agoHaha, its so funny! especially considering the fact that http://www.cucumbertown.com http://www.cucumbertown.com is a recipe site :)