Get the date relevant to the delta from today's date
(date, delta)
| 45 | |
| 46 | |
| 47 | def monthdelta(date, delta): |
| 48 | """ |
| 49 | Get the date relevant to the delta from today's date |
| 50 | """ |
| 51 | m, y = (date.month + delta) % 12, date.year + ((date.month) + delta - 1) // 12 |
| 52 | if not m: |
| 53 | m = 12 |
| 54 | d = min( |
| 55 | date.day, |
| 56 | [ |
| 57 | 31, |
| 58 | 29 if y % 4 == 0 and not y % 400 == 0 else 28, |
| 59 | 31, |
| 60 | 30, |
| 61 | 31, |
| 62 | 30, |
| 63 | 31, |
| 64 | 31, |
| 65 | 30, |
| 66 | 31, |
| 67 | 30, |
| 68 | 31, |
| 69 | ][m - 1], |
| 70 | ) |
| 71 | return date.replace(day=d, month=m, year=y) |
| 72 | |
| 73 | |
| 74 | def get_int_for_unk_type(dtype): |