views:

48

answers:

2

Please forgive my naivette...a very fundamental question:

I have a google app engine project that has a cron job that fetches records with date matching the current system date. This cron job triggers at 0:00 (ie, 12:00AM midnight) everyday. The cron job is apparently fetching records corresponding to the previous day. What could be wrong?

Has it got anything to do with the delay involved with updation of system date at 0:00? I was assuming that cal to get system date at 12:00AM would give the new day's date. Am I wrong?

+4  A: 

Time zones... the system may be working in UTC or, at least, something other than the time zone you expect.

Andrew McGregor
indeed Andrew..the server uses UTC...figured out that I'll have to make adjustments to the time before I use it..thanks
Aadith
+2  A: 

You should configure your cron.yaml file like this:

- description: midnight task
  url: /path/to/task
  schedule: every day 00:00
  timezone: Asia/Kolkata

See the docs.

The problem is that date-time values are stored as and returned using the UTC time zone and that can't be changed. You should treat this when updating your records. More info available here and here.

jbochi
thanks..but i am not storing the date values as such..i have two separate int fields...one for date and one of month (i only need those two)
Aadith
the configuration in my cron.xml is an exact equivalent of what you have mentioned above
Aadith
@Aadith: Even if you save the date as an integer, you should first convert the datetime to your timezone and do the conversion to int afterwards, otherwise the date will be saved according to UTC timezone.
jbochi