Thursday, May 28, 2015

Why the extra minute in PostgreSQL when using time zone info?

I am creating some test data for a DateTimeField using the following function:

    def rndDtTm(self):
        uktz = timezone('Europe/London')
        year = 2015
        month = 6
        day = randint(1, 30)
        hour = randint(0, 23)
        minute = 30 * randint(0, 1)
        return datetime(year, month, day, hour, minute, 0, 0, tzinfo = uktz)

When I look at the PostgreSQL field in pgAdminIII the times are either 1 or 31 minutes past the hour:
2015-06-10 22:01:00+01
2015-06-12 21:31:00+01

I was expecting them to be 0 or 30 minutes past the hour.  Why the extra minute?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/156ff7ce-9252-4384-9eaa-7e4b23a3880c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment