Beispiel #1
0
    def testTimeZoneTimestamp(self):
        sec_diff = 1000
        my_date = datetime.datetime.utcfromtimestamp(sec_diff)
        my_date = my_date.replace(tzinfo=timezone('Etc/GMT-8'))

        pst_diff = sec_diff - (8 * 3600.0)
        self.assertEqual(timestamp.utctimestamp(my_date), float(pst_diff))
Beispiel #2
0
  def testTimeZoneTimestamp(self):
    sec_diff = 1000
    my_date = datetime.datetime.utcfromtimestamp(sec_diff)
    my_date = my_date.replace(tzinfo=timezone('Etc/GMT-8'))

    pst_diff = sec_diff - (8 * 3600.0)
    self.assertEqual(timestamp.utctimestamp(my_date), float(pst_diff))
Beispiel #3
0
def _get_last_action(directory, action):
  """Get the last time the given action was run in the actions.log."""
  actions_log_file = os.path.join(directory, 'actions.log')
  if not os.path.exists(actions_log_file):
    return None
  with open(actions_log_file) as f:
    for line in reversed(list(f)):
      if action in line:
        unparsed_date = line.split(action)[0][len('**'):]
        return timestamp.utctimestamp(parse(unparsed_date))
  return None
Beispiel #4
0
def _get_last_action(directory, action):
    """Get the last time the given action was run in the actions.log."""
    actions_log_file = os.path.join(directory, "actions.log")
    if not os.path.exists(actions_log_file):
        return None
    with open(actions_log_file) as f:
        for line in reversed(list(f)):
            if action in line:
                unparsed_date = line.split(action)[0][len("**") :]
                return timestamp.utctimestamp(parse(unparsed_date))
    return None
Beispiel #5
0
 def testTimestamp(self):
     sec_diff = 1000
     my_date = datetime.datetime.utcfromtimestamp(sec_diff)
     self.assertEqual(timestamp.utctimestamp(my_date), float(sec_diff))
Beispiel #6
0
def parse_zulu_ts(string):
  """Parses Zulu time and converts into a timestamp or None."""
  zuluparse = parse_zulu_time(string)
  if zuluparse is None:
    return None
  return timestamp.utctimestamp(zuluparse)
Beispiel #7
0
 def testTimestamp(self):
   sec_diff = 1000
   my_date = datetime.datetime.utcfromtimestamp(sec_diff)
   self.assertEqual(timestamp.utctimestamp(my_date), float(sec_diff))
Beispiel #8
0
def parse_zulu_ts(string):
    """Parses Zulu time and converts into a timestamp or None."""
    zuluparse = parse_zulu_time(string)
    if zuluparse is None:
        return None
    return timestamp.utctimestamp(zuluparse)