Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-19 Thread Random832
On Sat, Apr 16, 2022, at 13:35, Peter J. Holzer wrote: > When adding a timedeltacal object to a datetime, the fields are added > from most to least significant: First a new date is computed by > advancing the number of months specified [TODO: Research how other > systems handle overflow (e.g. 2022-

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-18 Thread Barry
> On 18 Apr 2022, at 13:01, Peter J. Holzer wrote: > > On 2022-04-16 20:25:45 +0100, Barry wrote: >> Suggest that you start with the use cases that you want supported. >> Then you can turn them into a set of tests to check that the solution works. > > Writing test cases is always a good idea

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-18 Thread Peter J. Holzer
On 2022-04-16 20:25:45 +0100, Barry wrote: > Suggest that you start with the use cases that you want supported. > Then you can turn them into a set of tests to check that the solution works. Writing test cases is always a good idea :-) I have now written a first set of test cases: https://git.hjp

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-17 Thread Peter J. Holzer
On 2022-04-17 10:15:54 +0200, Peter J. Holzer wrote: > On 2022-04-17 06:08:54 +1000, Chris Angelico wrote: > > On Sun, 17 Apr 2022 at 03:37, Peter J. Holzer wrote: > > > Therefore a new class (provisionally called timedeltacal, because it is > > > calendaric, not absolute) should be added to datet

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-17 Thread Karsten Hilbert
Am Sun, Apr 17, 2022 at 11:10:01AM +1200 schrieb Greg Ewing: > On 17/04/22 9:17 am, Karsten Hilbert wrote: > > Take this medication for 1 month ! > > > >is quite likely to mean "take it for 28 days". > > Except when your doctor prescribes 90 days worth of tablets, It *still* means "take for 2

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-17 Thread Chris Angelico
On Sun, 17 Apr 2022 at 18:17, Peter J. Holzer wrote: > > On 2022-04-17 06:08:54 +1000, Chris Angelico wrote: > > On Sun, 17 Apr 2022 at 03:37, Peter J. Holzer wrote: > > > Datetime arithmetic in the real world is typically not done in seconds, > > > but in calendaric units: Hours, days, weeks, mo

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-17 Thread Peter J. Holzer
On 2022-04-17 06:08:54 +1000, Chris Angelico wrote: > On Sun, 17 Apr 2022 at 03:37, Peter J. Holzer wrote: > > Datetime arithmetic in the real world is typically not done in seconds, > > but in calendaric units: Hours, days, weeks, months, years, ... > > The problem is that several of these have v

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-16 Thread Greg Ewing
On 17/04/22 9:17 am, Karsten Hilbert wrote: Take this medication for 1 month ! is quite likely to mean "take it for 28 days". Except when your doctor prescribes 90 days worth of tablets, they come boxes of 84 (6 cards * 14 tablets), and the pharmacist dutifully opens a box, cuts off an

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-16 Thread Karsten Hilbert
Am Sat, Apr 16, 2022 at 07:35:51PM +0200 schrieb Peter J. Holzer: > So I'll start by gathering some feedback > here with a rough sketch. > [TODO: Research how other systems handle overflow > (e.g. 2022-01-31 + 1 month: 2022-02-31 doesn't exist)], That is context dependant: Take this med

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-16 Thread Chris Angelico
On Sun, 17 Apr 2022 at 03:37, Peter J. Holzer wrote: > Datetime arithmetic in the real world is typically not done in seconds, > but in calendaric units: Hours, days, weeks, months, years, ... > The problem is that several of these have varying lengths: > > * 1 minute may be 60 or 61 seconds (theo

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-16 Thread Barry
> On 16 Apr 2022, at 18:38, Peter J. Holzer wrote: > > I intend to take this to python-ideas, but I'm not currently subscribed > there and I think I should probably do a bit of research before > proposing something over there. So I'll start by gathering some feedback > here with a rough sketch

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-16 Thread Peter J. Holzer
On 2022-04-16 19:35:51 +0200, Peter J. Holzer wrote: > Note that t + d - d is in general not equal to t. > > We can't cnange the semantics of datetime - datetime, so there must be a > function to compute the difference between to datetimes as a > timedeltacal. It could be a method on datetime (may

Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-16 Thread Peter J. Holzer
I intend to take this to python-ideas, but I'm not currently subscribed there and I think I should probably do a bit of research before proposing something over there. So I'll start by gathering some feedback here with a rough sketch. Datetime arithmetic in the real world is typically not done in