From 8fdf3aa5a8587ef1d8f43aff7018f3bdb4a39c54 Mon Sep 17 00:00:00 2001 From: Chris Moore Date: Tue, 17 May 2011 02:03:39 -0700 Subject: [PATCH] The calendar dialog defaults to the current date, but the day can be configured to start later than midnight. Take this into account. and default to yesterday if appropriate. --- pyfpdb/Filters.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Filters.py b/pyfpdb/Filters.py index ce1410cc..70d9a2fa 100644 --- a/pyfpdb/Filters.py +++ b/pyfpdb/Filters.py @@ -25,7 +25,7 @@ import gtk import os import sys from optparse import OptionParser -from time import gmtime, mktime, strftime, strptime +from time import gmtime, mktime, strftime, strptime, localtime import gobject #import pokereval @@ -1134,6 +1134,14 @@ class Filters(threading.Thread): cal = gtk.Calendar() vb.pack_start(cal, expand=False, padding=0) + # if the day is configured to not start at midnight, check whether it's still yesterday, + # and if so, select yesterday in the calendar instead of today + now = localtime() + if (now.tm_hour < self.day_start): + yesterday = localtime(mktime(now) - 24*3600) + cal.select_month(yesterday.tm_mon - 1, yesterday.tm_year) # months are 0 through 11 + cal.select_day(yesterday.tm_mday) + btn = gtk.Button(_('Done')) btn.connect('clicked', self.__get_date, cal, entry, d) -- 2.11.4.GIT