Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wxpython datetime control?

Status
Not open for further replies.

j2ecoder

Programmer
Joined
Jan 2, 2006
Messages
5
Location
PH
Hello,

Why is it that the month e.g. January starts with 0? I think it is confusing.

dt = wxDateTime()
dt.Set(1,1,2002) # (day, month, year), this will be February

How can I make it start with 1?

Thanks for any hints.
 
Hello,

Actually is not so strange. The second parameter is an enumeration type.

From WxWidgets sources:

The function prototype, located in datetime.h is:

wxDateTime& Set(wxDateTime_t day,
Month month,
int year = Inv_Year, // 1999, not 99 please!
wxDateTime_t hour = 0,
wxDateTime_t minute = 0,
wxDateTime_t second = 0,
wxDateTime_t millisec = 0);
Where month is an enumeration declared internaly into wxDateTime class as:

enum Month
{
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, Inv_Month
};

When you are passing 0, it is casted to the Month enumeration type and correspond to Jan.

Why the enumeration should start with value 1, WxWidgets is a C++ library and for a C++ programmer everything starts with 0.

And WxPython is only a Python package calling the WxWidgets C++ library.

I guess you can use an intermediary variable to do this, but this practice is not normal nor recommended.

BTW, I used the WxWidgets C++ library, but never WxPython, what is your impression on WxPython ?

Thank you.

Adrian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top