Time Left ========= Let's consider a :class:`str` ``s`` with a text ended by a dot ``'.'`` with two parts separated by the word ``'and'``. For instance, consider the text ``'Your class starts at 10:05:00 and it is now 07:30:30.'``. If we exclude the ``'and'`` and the ``'.'`` then the two parts are ``'Your class starts at 10:05:00``` and ``'it is now 07:30:30'``. Each part includes a *time* right at the end: in the first part it is right before the word ``'and'`` (separated by a space ``' '``) and in the second part it is right before the dot character (``'.'``). As you can see in the example, a *time* is represented by the format ``hh/mm/ss`` with three two-digit figures separatd by ``'/'`` correspondng to *hours*, *mimutes* and *seconds* respectively. The first time is when a class will start and the second is the current time. We wish to get a text indicating the time left until class starts. The format required is ``'The class starts in XD hours, XM minutes and XS seconds.'``, except if the time left is less than 10 minutes in which case the format required is ``'Hurry up! The class starts in XM minutes and XS seconds.'``. In both texts *XH*, *XM*, and *XS* are the hours, minutes and seconds left until class starts, respectively. You are required to deliver the following functions (they have the same grade weight) in the module :mod:`time_module` (file :file:`time_module.py`): Firstly, an auxiliar function specified as follows: .. py:function:: extract_time(s) such that **given** *s* a :class:`str` with a time in the format described above **returns** 3 :class:`int` corresponding to the hours, minutes and seconds of that time in this order. For example: .. literalinclude:: extract_time.test :language: python3 :start-after: --ini :end-before: --fi Doctests are available in the :download:`extract_time.test` file. ------------------------------------------------------------------------------------------ Secondly, the main function: .. py:function:: time_left(s) such that **given** *s* a :class:`str` with the format described above. **returns** a :class:`str` generated as described above. For example: .. literalinclude:: time_left.test :language: python3 :start-after: --ini :end-before: --fi Doctests are available in the :download:`time_left.test` file. To code this function you have two code snippets available (which should be very helpful): #. The previous function **extract_time**. #. The function **time_dif** function that computes the difference of two given times. It's specification is: .. py:function:: time_dif(h1, m1, s1, h2, m2, s2) such that **given** *h1, m1, s1, h2, m2, s2*, :class:`int` where *h1*, *m1*, *s1* represent a time *t1* expressed in hours, minutes and seconds, and equally *h2*, *m2*, *s2* fortime *t2*, and *t1 <= t2*. **returns** three :class:`int` *h, m ,s* that represent the difference in amount of hours, minutes and seconds respectively between *t1* and *t2* (namely *t2*-*t1*) such that *0 <= m < 60* and *0 <= s < 60*. For example: .. literalinclude:: time_dif.test :language: python3 :start-after: --ini :end-before: --fi The code of this function can be downloaded from :download:`time_dif.py`. You can either import it or copy the code in your *time_module*.