From 704531e2ed007d3f53b2e4eb4d966ced226b6a06 Mon Sep 17 00:00:00 2001 From: "Rob G. Healey" Date: Tue, 17 May 2011 21:41:33 +0000 Subject: [PATCH] Added code to make sure that the entered day is not larger than the amount of days for the entered year and month in the date. svn: r17526 --- src/plugins/gramplet/EditExifMetadata.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plugins/gramplet/EditExifMetadata.py b/src/plugins/gramplet/EditExifMetadata.py index 0e67b4808..44d1b179e 100644 --- a/src/plugins/gramplet/EditExifMetadata.py +++ b/src/plugins/gramplet/EditExifMetadata.py @@ -1435,15 +1435,15 @@ class EditExifMetadata(Gramplet): # update Date/ Time spin buttons... self.update_spinners(year, month, day, hour, minutes, seconds) - def update_spinners(self, year, month, day, hour, minutes, seconds): + def update_spinners(self, syear, smonth, day, hour, minutes, seconds): """ - update Date/ Time spinners + update Date/ Time spinners. """ # split the date/ time into its six pieces... datetimevalues = { - "Year" : year, - "Month" : month, + "Year" : syear, + "Month" : smonth, "Day" : day, "Hour" : hour, "Minutes" : minutes, @@ -1451,6 +1451,14 @@ class EditExifMetadata(Gramplet): for widget, value in datetimevalues: + # make sure that the amount of days for that year and month is not > than the number of days selected... + if widget == "Day": + numdays = [0] + [calendar.monthrange(year, month)[1] for year in [syear] + for month in range(1, 13) ] + + if value > numdays[smonth]: + value = numdays[smonth] + # set the date/ time spin buttons... self.exif_widgets[widget].set_value(value)