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 the day is for
> 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
À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
--
À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
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
> 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
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.
À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
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
Às 05:44 de 21/06/22, Paul Bryan escreveu:
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.month - 1 + n) % 12 +
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 =
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 example
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.month - 1 + n) % 12 + 1
day = min(value.day,
14 matches
Mail list logo