Exemplo n.º 1
0
def write_date(system_time: Union[int, float]) -> bytes:
    if system_time == IMMEDIATELY:
        return ntp.IMMEDIATELY

    try:
        return ntp.system_time_to_ntp(system_time)
    except ntp.NtpError as ntpe:
        raise BuildError(ntpe)
Exemplo n.º 2
0
def write_date(system_time):
  if system_time == IMMEDIATELY:
    return ntp.IMMEDIATELY

  try:
    return ntp.system_time_to_ntp(system_time)
  except ntp.NtpError as ntpe:
    raise BuildError(ntpe)
Exemplo n.º 3
0
def write_date(system_time):
    if system_time == IMMEDIATELY:
        return ntp.IMMEDIATELY

    try:
        return ntp.system_time_to_ntp(system_time)
    except ntp.NtpError as ntpe:
        raise BuildError(ntpe)
Exemplo n.º 4
0
def write_date(system_time: Union[int, float]) -> bytes:
    if system_time == IMMEDIATELY:
        return ntp.IMMEDIATELY

    try:
        return ntp.system_time_to_ntp(system_time)
    except ntp.NtpError as ntpe:
        raise BuildError(ntpe)
Exemplo n.º 5
0
 def test_nto_to_system_time(self):
     unix_time = time.time()
     timestamp = ntp.system_time_to_ntp(unix_time)
     unix_time2 = ntp.ntp_to_system_time(timestamp)
     self.assertTrue(type(unix_time) is float)
     self.assertTrue(type(timestamp) is bytes)
     self.assertTrue(type(unix_time2) is float)
     self.assertEqual(round(unix_time, 6), round(unix_time2, 6))
Exemplo n.º 6
0
def write_date(system_time):
  if system_time == IMMEDIATELY:
    return ntp.IMMEDIATELY
  elif isinstance(system_time,int):
    return struct.pack('>Q', system_time)

  try:
    return ntp.system_time_to_ntp(system_time)
  except ntp.NtpError as ntpe:
    raise BuildError(ntpe)
Exemplo n.º 7
0
 def test_system_time_to_ntp(self):
   self.assertTrue(ntp.system_time_to_ntp(0.0))
Exemplo n.º 8
0
def write_date(system_time):
  if system_time == IMMEDIATELY:
    return ntp.IMMEDIATELY

  return ntp.system_time_to_ntp(system_time)
Exemplo n.º 9
0
def write_date(system_time):
    if system_time == IMMEDIATELY:
        return ntp.IMMEDIATELY

    return ntp.system_time_to_ntp(system_time)