def get_issued_date(dataset_id): """ Cleans the value provided to get the issued date of the dataset. :param str dataset_id: Dataset's stored identifier. :return: The issued date in UTC ISO 8601 format. :rtype: str """ time_uuid = TimeUUID.convert(uuid.UUID('{%s}' % dataset_id)) return Helpers.format_datetime(time_uuid.get_datetime())
def get_ts_for_timeuuid(timeuuid, cassandra=False, iso=False): ''' Extracts timestamp from TimeUUID. By default, returns datetime.datetime. Returns iso 8166 timestamp string if iso == True ''' try: if cassandra == True: timeuuid = TimeUUID.convert(timeuuid) ts = TimeUUID.get_datetime(timeuuid) except: e = "get_ts_for_timeuuid: %r is not a time_uuid.TimeUUID, is %r." % \ (timeuuid, type(timeuuid)) raise ValueError(e) if iso: return ts.isoformat() else: return ts
def time_uuid(self, value): if value is not None: self._time_uuid = TimeUUID.convert(value) else: self._time_uuid = None
def test_get_time(self): utc_time = datetime.utcnow() log_entry = CassandraLogEntry(time_uuid=TimeUUID.convert(utc_time)) assert log_entry.time == utc_time
# |--ServerID :string # | # +ReadingListNonSync # |--AddedLocally :bool # | # |WebBookmarkType :string # |WebBookmarkUUID :string # |URLString :string # | # +ReadingList # |--DateAdded :date # #print("%s\n%s\n%s\n%s\n" % (title, time_added, href, tags)) WebBookmarkUUID = TimeUUID.convert(long(time_added), randomize=False).get_urn()[9:] have = False for sub_item in sub_items: if sub_item['WebBookmarkUUID'] == WebBookmarkUUID: have = True break if have: continue DateAdded = dt.utcfromtimestamp(long(time_added)) entry = dict() URIDictionary = dict() Sync = dict()
def _create_time_uuid(date_time_string): return TimeUUID.convert(arrow.get(date_time_string).datetime)