On Sat, Jan 10, 2015 at 2:02 AM, André Roberge <andre.robe...@gmail.com> wrote:
> On Friday, 9 January 2015 19:09:15 UTC-4, stephen...@gmail.com  wrote:
>> One issue is the format returned for the calendar selection. For today, the 
>> string returned is "Fri Jan 9 2015". My script needs to convert the date to 
>> a datetime.date, and having the month returned as a string instead of an 
>> integer makes this harder.
>
> Would today's date be represented as the string "09.01.2015" useful to you? 
> (I found out how to do this.)  If so, I could perhaps add an argument like 
> numeric_format = True.

The correct way to handle this is to use cal.date.toPyDate(), which
helpfully returns a datetime.date object — and make this the default
output of the calendar function, because that’s the only useful output
for anyone asking for a date.

>>> date
'Sat Jan 10 2015'
>>> cal.date
PyQt4.QtCore.QDate(2015, 1, 10)
>>> cal.date.toPyDate()
datetime.date(2015, 1, 10)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to