datetime question

V

Victor Subervi

Hi;
I have this code:

today = datetime.date.today()
day = today.day
mo = today.month
yr = today.year

Works great. What I need to calculate is the length of days in the
given month. How do I do that?
TIA,
Victor
 
A

Albert Hopkins

The ‘datetime’ module focusses on individual date+time values (and the
periods between them, with the ‘timedelta’ type).

For querying the properties of the calendar, use the ‘calendar’
module.

Yes, it would be nice if the ‘time’, ‘datetime’, and ‘calendar’
modules
were all much more unified and consumed a common set of primitive
date+time types. It's a wart, and fixing it would (unfortunately)
probably require backward-incompatible API changes.

But, supposedly, that's why we had Python3.
 
A

Albert Hopkins

Fixing ‘time’, ‘datetime’, and ‘calendar’ was the reason for Python 3?
No, it wasn't.

Or perhaps you mean that any backward-incompatible change was a reason
to have Python 3? Even more firmly no. The extent of changes was
severely limited to make the transition from Python 2 to Python 3 as
painless as feasible, while still meeting the goals of Python 3.

No, I meant "cleaning up the standard library in spite of
incompatibilities" was one of the goals of Python3 (PEP 3108).
Personally I don't see anything wrong with the modules, but that was my
question to the person who said they should all be integrated but wasn't
because of incompatibilities.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,537
Latest member
BellCorone

Latest Threads

Top