Changeset 86956 in vbox for trunk/src/VBox/ValidationKit/testmanager/cgi
- Timestamp:
- Nov 23, 2020 10:41:20 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 141476
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/cgi/status.py
r86955 r86956 47 47 from testmanager.core.db import TMDatabaseConnection; 48 48 49 50 51 def how_many_days_in_month(year, month):52 def leap_year_check(year):53 if year % 4 == 0 and year % 100 != 0:54 return True55 if year % 100 == 0 and year % 400 == 0:56 return True57 return False58 59 month31 = (1, 3, 5, 7, 8, 10, 12)60 month30 = (4, 6, 9, 11)61 if month in month31:62 days = 3163 elif month in month30:64 days = 3065 else:66 if leap_year_check(year):67 days = 2968 else:69 days = 2870 return days71 72 73 def target_date_from_time_span(cur_date, time_span_hours):74 cur_year = cur_date.year75 cur_month = cur_date.month76 cur_day = cur_date.day77 cur_hour = cur_date.hour78 if cur_hour >= time_span_hours:79 return cur_date.replace(hour=cur_hour-time_span_hours)80 if cur_day > 1:81 return cur_date.replace(day=cur_day-1,82 hour=24+cur_hour-time_span_hours)83 if cur_month > 1:84 return cur_date.replace(month=cur_month-1,85 day=how_many_days_in_month(cur_year, cur_month-1),86 hour=24+cur_hour-time_span_hours)87 return cur_date.replace(year=cur_year-1,88 month=12,89 day=31,90 hour=24+cur_hour-time_span_hours)91 49 92 50
Note:
See TracChangeset
for help on using the changeset viewer.