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: 58
  1. def compare_dates(y1, m1, d1, y2, m2, d2):
  2.     """
  3.    Если даты равны - вернуть 0
  4.    если date1 меньше date2 - вернуть -1
  5.    если date1 больше date2 - вернуть 1
  6.    """
  7.  
  8.     if y1 == y2 and m1 == m2 and d1 == d2:
  9.         return 0
  10.     elif y1 > y2 or (y1 == y2 and m1 > m2) or (y1 == y2 and m1 == m2 and d1 > d2):
  11.         return 1
  12.     else:
  13.         return -1
  14.  
  15. def test_compare_dates():
  16.  
  17.     assert compare_dates(2020, 9, 26, 2020, 9, 26) == 0
  18.     assert compare_dates(2020, 9, 25, 2020, 9, 26) == -1
  19.     assert compare_dates(2020, 9, 27, 2020, 9, 26) == 1
  20.  
  21.     assert compare_dates(2020, 9, 26, 2020, 10, 26) == -1
  22.     assert compare_dates(2020, 9, 26, 2020, 8, 26) == 1
  23.  
  24.  
  25. if __name__ == '__main__':
  26.     test_compare_dates()
  27.     name = 'Ковинский Руслан'  # TODO: напишите Ваше имя
  28.     print(f'26 сентября - {name}')
  29.