diff --git a/chess/__init__.py b/chess/__init__.py index c92505ce6..135eacf2d 100644 --- a/chess/__init__.py +++ b/chess/__init__.py @@ -34,6 +34,7 @@ import re import itertools import typing +import time from typing import ClassVar, Callable, Dict, Generic, Hashable, Iterable, Iterator, List, Mapping, MutableSet, Optional, SupportsInt, Tuple, Type, TypeVar, Union @@ -386,6 +387,21 @@ def _rays() -> Tuple[List[List[Bitboard]], List[List[Bitboard]]]: FEN_CASTLING_REGEX = re.compile(r"^(?:-|[KQABCDEFGH]{0,2}[kqabcdefgh]{0,2})\Z") +class Time: + """keeps time at the beginning of the game""" + Starting_Time = int(round(time.time())) + + """returns the current running time""" + def get_time(self) -> str: + playing_time = int(round(time.time())) - self.Starting_Time + + hours = playing_time / 3600 + less_than_an_hour = playing_time % 3600 + minutes = less_than_an_hour / 60 + seconds = less_than_an_hour % 60 + + Time = 'hours: %d minutes: %d seconds: %d' % (hours, minutes, seconds) + return Time class Piece: """A piece with type and color."""