コード例 #1
0
 def test_time(self):
     c = Calendar()
     c = c.add(Day("came 9 left 15", today))
     data = c.dump()
     c2 = Calendar.load(data)
     assert c2.days[today].came == time(9)
     assert c2.days[today].left == time(15)
コード例 #2
0
ファイル: day.py プロジェクト: Godsmith/timereporter
 def _to_time(cls, t: Union[time, timedelta, None]) -> Union[time, None]:
     if t is None:
         return None
     if isinstance(t, time):
         return t
     hour = t.seconds // 3600
     minute = (t.seconds - hour * 3600) // 60
     return time(hour=hour, minute=minute)
コード例 #3
0
    def as_time(cls, str_: str) -> Union[time, timedelta]:
        """Parses a string on the format specified below.

        If the string is not on the specified format, a TimeParserError
        is raised.

        :param str_: A string on the form H, HH:MM, H:MM,
        HHMM, HMM, M m, MM m, M min or MM min
        :return: a datetime.time or datetime.timedelta object corresponding to the input string
        """
        hours, minutes = cls._to_hours_and_minutes(str_)
        return time(hour=hours, minute=minutes)
コード例 #4
0
 def test_basic(self):
     assert str(time(hour=7, minute=45)) == "07:45"
コード例 #5
0
 def test_overwrite_all(self):
     c = Calendar()
     c = c.add(Day("came 9 left 15", today))
     c = c.add(Day("came 8 left 14", today))
     assert c.days[today].came == time(8)
     assert c.days[today].left == time(14)
コード例 #6
0
 def test_add_to_day_inverse_order(self):
     c = Calendar()
     c = c.add(Day("left 15", today))
     c = c.add(Day("came 9", today))
     assert c.days[today].came == time(9)
     assert c.days[today].left == time(15)
コード例 #7
0
 def test_add_day(self):
     c = Calendar()
     c = c.add(Day("came 9 left 15", today))
     assert c.days[today].came == time(9)
     assert c.days[today].left == time(15)
コード例 #8
0
ファイル: test_day.py プロジェクト: Godsmith/timereporter
 def test_to_timedelta(self):
     assert Day._to_timedelta(time(
         hour=5, minute=37)) == timedelta(seconds=5 * 3600 + 37 * 60)
コード例 #9
0
ファイル: test_day.py プロジェクト: Godsmith/timereporter
 def test_to_time(self):
     assert Day._to_time(timedelta(hours=5, minutes=37)) == time(hour=5,
                                                                 minute=37)