Skip to content

handle correctly addToDate when add/remove month

Xiaowu Zhang requested to merge xiaowu.zhang/erp5:feature into master

after https://lab.nexedi.com/nexedi/erp5/-/merge_requests/1768, addToDate start to have strange behavior

  
march_31 = DateTime('2001/03/31')

print(addToDate(march_31, month=1, day=1))
2001/05/01 00:00:00 UTC  ✔️
print(addToDate(march_31, month=1, hour=24))
2001/04/30 00:00:00 UTC  
print(addToDate(march_31, hour=24))
2001/03/31 00:00:00 UTC  
print(addToDate(march_31, month=-1, day=-1))
2001/02/27 00:00:00 UTC  ✔️
print(addToDate(march_31, month=-1, hour=-24))
2001/02/28 00:00:00 UTC  

the propose of this MR is to fix it

Edited by Xiaowu Zhang

Merge request reports