def test_030_now_with_argument(self):
        "Return an object that represents the current moment in the day."
        # for the time being, let's use the good old datetime module :-)
        import datetime

        # we must ensure that at least once in three times we get the same values in seconds
        count = 0
        while count < 3:
            datetime_now = datetime.datetime.utcnow()
            datetime_frac_seconds = datetime_now.hour * 3600 + datetime_now.minute * 60 + datetime_now.second
            time_now = Time.now(to_utc=0)
            if int(time_now.day_frac * 86400) == datetime_frac_seconds:
                break
            count += 1
        assert count < 3, "Unable to get at least one a correct Time.now(to_utc=0)"
        assert time_now.to_utc == 0

        # again but with class
        count = 0
        while count < 3:
            datetime_now = datetime.datetime.utcnow()
            datetime_frac_seconds = datetime_now.hour * 3600 + datetime_now.minute * 60 + datetime_now.second
            time_now = Time.now(to_utc=DummyTZ(0, 1))
            if int(time_now.day_frac * 86400) == datetime_frac_seconds:
                break
            count += 1
        assert count < 3, "Unable to get at least one a correct Time.now(to_utc=DummyTZ(0, 1))"
        assert time_now.to_utc == 0
Exemple #2
0
    def test_030_now_with_argument(self):
        """Return an object that represents the current moment in the day."""
        # for the time being, let's use the good old datetime module :-)
        import datetime

        # we must ensure that at least once in three times we get the same values in seconds
        count = 0
        while count < 3:
            datetime_now = datetime.datetime.utcnow()
            time_now = Time.now(to_utc=0)
            datetime_frac_seconds = (
                    datetime_now.hour * 3600
                    + datetime_now.minute * 60
                    + datetime_now.second
            )
            if int(time_now.day_frac * 86400) == datetime_frac_seconds:
                break
            count += 1
        assert count < 3, "Unable to get at least one a correct Time.now(to_utc=0)"
        assert time_now.to_utc == 0

        # again but with class
        count = 0
        while count < 3:
            datetime_now = datetime.datetime.utcnow()
            time_now = Time.now(to_utc=DummyToUtc(0, 1))
            datetime_frac_seconds = (
                    datetime_now.hour * 3600
                    + datetime_now.minute * 60
                    + datetime_now.second
            )
            if int(time_now.day_frac * 86400) == datetime_frac_seconds:
                break
            count += 1
        assert count < 3, "Unable to get at least one a correct Time.now(to_utc=DummyToUtc(0, 1))"
        assert time_now.to_utc == 0
    def test_020_now(self):
        "Return an object that represents the current moment in the day."
        # for the time being, let's use the good old datetime module :-)
        import datetime, time

        # we must ensure that at least once in three times we get the same values in seconds
        count = 0
        while count < 3:
            datetime_now = datetime.datetime.now()
            datetime_frac_seconds = datetime_now.hour * 3600 + datetime_now.minute * 60 + datetime_now.second
            time_now = Time.now()
            if int(time_now.day_frac * 86400) == datetime_frac_seconds:
                break
            count += 1
        assert count < 3, "Unable to get at least one a correct Time.now()"
        assert int(time_now.to_utc) == time.timezone
Exemple #4
0
    def test_020_now(self):
        """Return an object that represents the current moment in the day."""
        # for the time being, let's use the good old datetime module :-)
        import datetime, time

        # we must ensure that at least once in three times we get the same values in seconds
        count = 0
        while count < 3:
            datetime_now = datetime.datetime.now()
            time_now = Time.now()
            datetime_frac_seconds = (
                    datetime_now.hour * 3600
                    + datetime_now.minute * 60
                    + datetime_now.second
            )
            if int(time_now.day_frac * 86400) == datetime_frac_seconds:
                break
            count += 1
        assert count < 3, "Unable to get at least one a correct Time.now()"
        assert int(time_now.to_utc) == time.timezone