On 2022-06-21 05:29:52 +0100, Paulo da Silva wrote:
> I implemented a part of a script to subtract n months from datetime.
> Basically I subtracted n%12 from year and n//12 from the month adding 12
> months when it goes<=0. Then used try when converting to datetime again. So,
> if
> What makes sense depends on where you're looking from.
>
> It's 28 February, you need to keep it for 5 years, therefore you could
> reason that you can dispose of it on 28 February, 5 years hence.
>
> However, that happens to be a leap year.
>
> Should you still have it on 29 February?
Nope beca
Às 19:47 de 22/06/22, Marco Sulla escreveu:
The package arrow has a simple shift method for months, weeks etc
https://arrow.readthedocs.io/en/latest/#replace-shift
At first look it seems pretty good! I didn't know it.
Thank you Marco.
Paulo
--
https://mail.python.org/mailman/listinfo/python-l
Às 20:25 de 22/06/22, Barry Scott escreveu:
On 22 Jun 2022, at 17:59, Paulo da Silva
wrote:
Às 05:29 de 21/06/22, Paulo da Silva escreveu:
As a general response to some comments ...
Suppose we need to delete records from a database older than ...
Today, it's usual to specify days. For exa
On 2022-06-22 20:25, Barry Scott wrote:
On 22 Jun 2022, at 17:59, Paulo da Silva
wrote:
Às 05:29 de 21/06/22, Paulo da Silva escreveu:
As a general response to some comments ...
Suppose we need to delete records from a database older than ...
Today, it's usual to specify days. For example
> On 22 Jun 2022, at 17:59, Paulo da Silva
> wrote:
>
> Às 05:29 de 21/06/22, Paulo da Silva escreveu:
>
> As a general response to some comments ...
>
> Suppose we need to delete records from a database older than ...
> Today, it's usual to specify days. For example you have to keep some go
The package arrow has a simple shift method for months, weeks etc
https://arrow.readthedocs.io/en/latest/#replace-shift
--
https://mail.python.org/mailman/listinfo/python-list
On 2022-06-22 17:59, Paulo da Silva wrote:
Às 05:29 de 21/06/22, Paulo da Silva escreveu:
As a general response to some comments ...
Suppose we need to delete records from a database older than ...
Today, it's usual to specify days. For example you have to keep some gov
papers for 90 days. This
Às 05:29 de 21/06/22, Paulo da Silva escreveu:
As a general response to some comments ...
Suppose we need to delete records from a database older than ...
Today, it's usual to specify days. For example you have to keep some gov
papers for 90 days. This seems to come from computers era. In our m
On 21Jun2022 17:02, Paulo da Silva wrote:
>I have a datetime, not a date.
Then you need a date. I would break the datetime into a date and a time,
then do the months stuff to the date, then compose a new datetime from
the result.
>Anyway, the use of calendar.monthrange simplifies the task a lo
me(*dtnow_t)
Any comments are welcome.
Thank you.
Paulo
On Tue, 2022-06-21 at 05:29 +0100, Paulo da Silva wrote:
Hi!
I implemented a part of a script to subtract n months from datetime.
Basically I subtracted n%12 from year and n//12 from the month adding
12
months when it goes<=0. Then used
On Mon, Jun 20, 2022 at 9:45 PM Paul Bryan wrote:
> Here's how my code does it:
>
>
> import calendar
>
> def add_months(value: date, n: int):
> """Return a date value with n months added (or subtracted if
> negative)."""
> year = value.year + (value.month - 1 + n) // 12
> month = (value.mo
On 6/21/22 12:29 AM, Paulo da Silva wrote:
Hi!
I implemented a part of a script to subtract n months from datetime.
Basically I subtracted n%12 from year and n//12 from the month adding
12 months when it goes<=0. Then used try when converting to datetime
again. So, if the day is for exam
min(value.day, calendar.monthrange(year, month)[1])
return date(year, month, day)
Paul
On Tue, 2022-06-21 at 05:29 +0100, Paulo da Silva wrote:
> Hi!
>
> I implemented a part of a script to subtract n months from datetime.
> Basically I subtracted n%12 from year and n//12 from the mo
Hi!
I implemented a part of a script to subtract n months from datetime.
Basically I subtracted n%12 from year and n//12 from the month adding 12
months when it goes<=0. Then used try when converting to datetime again.
So, if the day is for example 31 for a 30 days month it raises a
ValuEr
15 matches
Mail list logo