1. Is there a standard class for a 'period', i.e. length of time
   specified by a start point and an end point?  The start and end
   points could obviously be datetimes and the difference a timedelta,
   but the period '2022-03-01 00:00 to 2022-03-02 00:00' would be
   different to '2023-03-01 00:00 to 2023-03-02 00:00' even if the
   *duration* of both periods is the same.

But even if I have a single epoch, January 2022 is obviously different
to January 2023, even thought the duration might be the same.  I am just
surprised that there is no standard Period class, with which I could
create objects and then be able to sort, check for identity, equality of
length, amount of overlap, etc.  I suppose people just use a
datetime.datetime pair, as I have been doing so far, and tack on just
the specific bit of functionality they need.

The request for a "standard class" has probably been answered.

Please give a use-case example to help outline the problem to be solved...

eg if the Apple-picking season starts in January and runs for some weeks, and the Pear-picking season starts in February (etc), then calculation will reveal if one team of pickers can do both jobs or if two teams will be needed. If a list of tasks is to be displayed/printed, then it would be useful to list both, but in chronological order - perhaps by start-date. (this idea of possible application fails to illustrate a rationale for some of the functionality listed, above, but you get the idea of how to give us the idea...)

In a custom-class, an __eq__( self, other, ) may be defined to consider any single or combination of attributes of the two classes. So, roll-your-own may not be that difficult - although anything involving time-calculations is wont to open a can-of-worms...

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to