1. 24 Apr, 2023 35 commits
  2. 21 Apr, 2023 2 commits
    • Nicolas Wavrant's avatar
      erp5_core: fix addToDate when removing a month · c1dfe5d8
      Nicolas Wavrant authored
      See merge request nexedi/erp5!1768
      c1dfe5d8
    • Nicolas Wavrant's avatar
      erp5_core: fix addToDate when removing a month · 34d26a74
      Nicolas Wavrant authored
      The way addToDate was working with dates was not good, and creating
      confusion when removing 1 month from the last days of a 31-day month, as
      the previous day had less days than the current month:
      
      date = DateTime(2023, 5, 31)
      print date
      print addToDate(date, month=-1)
      > 2023/05/31 00:00:00 GMT+2
      > 2023/05/01 00:00:00 GMT+2
      
      This was even more confusing in March, with february having only 28
      days:
      
      date = DateTime(2023, 3, 31)
      print date
      print addToDate(date, month=-1)
      > 2023/03/31 00:00:00 GMT+2
      > 2023/03/03 00:00:00 GMT+2
      
      The new behavior is to, when removing a month, if the new day of the new
      month is more than the number of days in month to default to the last
      day of the month. For exemple, removing one month from 31/05 becomes
      30/04, and from there it will add/remove the days as necessary.
      
      The real issue being that removing a month is ambiguous and can mean
      a different thing for different people.
      
      For reference, the reference implementation of timedelta in python
      doesn't support adding months:
      
      https://docs.python.org/3/library/datetime.html#datetime.timedelta
      
      I hope my solution will make the more sense in ERP5's context.
      34d26a74
  3. 20 Apr, 2023 1 commit
  4. 17 Apr, 2023 1 commit
  5. 12 Apr, 2023 1 commit