After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 168513 - gtk.Calendar.get_date() reports the month in a manner inconsistent to other reporting
gtk.Calendar.get_date() reports the month in a manner inconsistent to other r...
Status: RESOLVED FIXED
Product: pygtk
Classification: Bindings
Component: documentation
2.5.x/2.6.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2005-02-25 15:39 UTC by Matt T. Proud
Modified: 2005-04-01 06:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the proposed patch (787 bytes, patch)
2005-03-30 19:36 UTC, Gian Mario Tagliaretti
none Details | Review
revised patch (1.18 KB, patch)
2005-03-31 23:10 UTC, Gian Mario Tagliaretti
none Details | Review

Description Matt T. Proud 2005-02-25 15:39:18 UTC
Distribution/Version: Ubuntu

gtk.Calendar.get_date() returns a tuple containing the year, month, and date in
the form of (Y, M, D). This is fine by nature, but consider what happens when I
perform the get_date() when I have today selected.

Today is 2005-02-25, where Y = 2005; M = 2; D = 25.
print calendar.get_date()
=> (2005, 1, 25)

This is inconsistent, because instead of returning (Y, M, D), it returns (Y,
M-1, D).

Take a look at this sample example:

#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk

def date_changed(cal):
	print cal.get_date()

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
calendar = gtk.Calendar()
window.add(calendar)
calendar.connect("day-selected", date_changed)
calendar.show()
window.show()
gtk.main()
Comment 1 Gian Mario Tagliaretti 2005-03-26 18:04:40 UTC
I think is correct the way it work, if you look at the method
gtk.Calendar.select_month the month is between 0 and 11.

We can discuss if is better this way or 1 to 12 but I don't think this is a bug.
Comment 2 Matt T. Proud 2005-03-26 18:37:23 UTC
Due to basic API inconsistencies, perhaps this issue should be forwarded to    
the GTK+ development team.    
  
From  
http://developer.gnome.org/doc/API/2.0/gtk/GtkCalendar.html#gtk-calendar-select-month:  
gboolean    gtk_calendar_select_month       (GtkCalendar *calendar,   
                                             guint month,   
                                             guint year);   
calendar: a GtkCalendar.    
month: a month number between 0 and 11.    
year: the year the month is in.    
   
void        gtk_calendar_select_day         (GtkCalendar *calendar,   
                                             guint day);   
Selects a day from the current month.    
calendar: a GtkCalendar.    
day: the day number between 1 and 31, or 0 to unselect the currently selected   
day.   
   
Do not get me wrong here, but such an inconsistency is absolutely outrageous   
on the part of the GTK+ developers. If everything is represented as (Y, M-1,  
D), then it should either be (Y, M, D) or (Y-1, M-1, D-1); I just cannot see a  
logical or justifiable reason to have such an exception.  
  
Yes, changing this behavior could mean going out and reverifying much code;  
but conversely, the change could be made now before the inconsistency  
propagates itself anymore than it has.  
 
I would strongly encourage changing the product of this bug to GTK+. 
Comment 3 Federico Mena Quintero 2005-03-28 17:43:43 UTC
struct tm in Unix uses a tm_mon in the range [0, 11].  I guess GTK+ does the
same for consistency, as quirky as it may be.
Comment 4 Gian Mario Tagliaretti 2005-03-30 19:36:17 UTC
Created attachment 39453 [details] [review]
the proposed patch

There was a discussion on gtk-app-devel about this subject:
http://mail.gnome.org/archives/gtk-app-devel-list/2005-March/msg00283.html

at the end was pointed out this part of the API reference:
http://developer.gimp.org/api/2.0/gtk/GtkCalendar.html#GtkCalendar-struct

where you can see the note about how gtk_calendar works, maybe is better to
include such a note also in pygtk reference manual?

If John Finlay will approve this I have prepared a patch.
Comment 5 John Finlay 2005-03-31 01:26:34 UTC
Should add to get_date() docs as well.
Comment 6 Gian Mario Tagliaretti 2005-03-31 23:10:17 UTC
Created attachment 39530 [details] [review]
revised patch
Comment 7 John Finlay 2005-04-01 06:36:39 UTC
	* pygtk-gtkcalendar.xml (Description, get_date): Add note about
	month value starting at zero. Patch by Gian Mario Tagliaretti.