Beispiel #1
0
def test_get_pretty(year: int, month: int, day: int, hour: int, minute: int,
                    second: int, pretty: str):
    values = (year, month, day, hour, minute, second, 0, 0, 0)
    st = struct_time(values)
    epoch = timegm(st)
    ti = TimeInt(epoch)
    assert ti.get_pretty() == pretty
Beispiel #2
0
def test_end_of_week_stamp():
    """Testing specific stamp Friday evening at 8:59 pm."""
    # This specific time is to give me confidence that values are really UAC and
    # not my local timezone. Got int from the last 1 minute candle downloaded
    # from the forex broker Oanda for a trading week. Forex trading weeks
    # end when it is 5pm in New York thus the last 1 minute candle would
    # start at 4:59 pm in New York, which means 8:59 pm in UTC.
    stamp_9_11_8_59_pm = 1599857940
    ti = TimeInt(stamp_9_11_8_59_pm)
    assert ti.year == 2020
    assert ti.month == 9
    assert ti.day == 11
    assert ti.weekday == 5
    assert ti.hour == 20
    assert ti.minute == 59
    assert ti.second == 0
    assert ti.get_pretty() == "2020-09-11 08:59 PM"
Beispiel #3
0
 def get_labels(self):
     second_year = TimeInt(self.time + _ApproxTimes.FAT_YEAR).trunc_year()
     return f"{self.time.get_pretty()}-", second_year.get_pretty()
Beispiel #4
0
 def get_labels(self):
     fifth_year = TimeInt(self.time +
                          4 * _ApproxTimes.FAT_YEAR).trunc_year()
     return f"{self.time.get_pretty()}-", fifth_year.get_pretty()