Facebook
From Алексей Бельденко, 3 Years ago, written in Python.
">

A PHP Error was encountered

Severity: Notice

Message: Trying to access array offset on value of type bool

Filename: view/view.php

Line Number: 33

from

A PHP Error was encountered

Severity: Notice

Message: Trying to access array offset on value of type bool

Filename: view/view.php

Line Number: 33

- view diff
Embed
Download Paste or View Raw
Hits: 67
  1. def compare_dates(y1, m1, d1, y2, m2, d2):
  2.     """
  3.   Если даты равны - вернуть 0
  4.   если date1 меньше date2 - вернуть -1
  5.   если date1 больше date2 - вернуть 1
  6.   """
  7.     if y1 == y2 and m1 == m2 and d1 == d2:
  8.         return 0
  9.     elif y1 < y2:
  10.         return -1
  11.     elif y1 == y2 and m1 < m2:
  12.         return -1
  13.     elif y1 == y2 and m1 == m2 and d1 < d2:
  14.         return -1
  15.     elif y1 > y2:
  16.         return 1
  17.     elif y1 == y2 and m1 > m2:
  18.         return 1
  19.     elif y1 == y2 and m1 == m2 and d1 > d2:
  20.         return 1
  21.  
  22.  
  23. def test_compare_dates():
  24.     assert compare_dates(2020, 9, 26, 2020, 9, 26) == 0
  25.     assert compare_dates(2020, 9, 25, 2020, 9, 26) == -1
  26.     assert compare_dates(2020, 9, 27, 2020, 9, 26) == 1
  27.  
  28.     assert compare_dates(2020, 9, 26, 2020, 10, 26) == -1
  29.     assert compare_dates(2020, 9, 26, 2020, 8, 26) == 1
  30.  
  31.  
  32. if __name__ == '__main__':
  33.     test_compare_dates()
  34.     name = 'Алексей Бельденко'  # TODO: напишите Ваше имя
  35.     print(f'26 сентября - {name}')
  36.