Create a UUID

 @param value [Time,String,Integer] timestamp to assign to the UUID, or
   numeric or string representation of the UUID
 @return a UUID appropriate for use with Cequel
161872
def uuid(value = nil)
      if value.nil?
        timeuuid_generator.now
      elsif value.is_a?(Time)
        timeuuid_generator.at(value)
      elsif value.is_a?(DateTime)
        timeuuid_generator.at(Time.at(value.to_f))
      else
        Type::Timeuuid.instance.cast(value)
      end
    end
189618
def timestamp(self, value):
        
        if not self._timestamp_is_valid(value):
            value = self._calculate_current_timestamp()
        self._timestamp = value
547834
def to_timestamp(self, value):
        
        if isinstance(value, (six.integer_types, float, six.string_types)):
            try:
                return float(value)
            except ValueError:
                value = self.datetime_str_to_datetime(value)

        if isinstance(value, datetime.datetime):
            return self._datetime_to_timestamp(value)

        if value is None:
            try:
                return float(self.default)
            except:
                return 0.0

        raise exceptions.ValidationError(
            "Unable to convert value: '%s' to timestamp" % value,
            code="invalid_timestamp"
        )
232967
public static java.sql.Time toTime(Object value) throws ParseException {
        if (value == null) {
            return null;
        }
        if (value instanceof java.sql.Time) {
            return (java.sql.Time) value;
        }
        if (value instanceof String) {
            if ("".equals((String) value)) {
                return null;
            }
            return new java.sql.Time(IN_TIME_FORMAT.parse((String) value).getTime());
        }

        return new java.sql.Time(IN_TIME_FORMAT.parse(value.toString()).getTime());
    }
1337928
public Datapoint addStringValue(long time, String value) {
        initialValues();
        checkType(TsdbConstants.TYPE_STRING);

        values.add(Lists.<JsonNode> newArrayList(new LongNode(time), new TextNode(value)));
        return this;
    }
1108844
public static Date asDate(Object value) {
        if (value instanceof Date) {
            return (Date) value;
        } else if (value instanceof CharSequence) {
            String date = value.toString().trim();
            try {
                LocalDateTime time;
                if (date.endsWith("Z")) {
                    time = LocalDateTime.parse((CharSequence) value,
                                               DateTimeFormatter.ISO_INSTANT.withZone(Clock.systemUTC().getZone()));
                } else {
                    time = LocalDateTime.parse((CharSequence) value,
                                               DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(Clock.systemUTC().getZone()));
                }
                return new Date(time.atZone(Clock.systemUTC()
                                                 .getZone()).toInstant().toEpochMilli());
            } catch (RuntimeException e) {
                throw new ConfigException(e, "Unable to parse date: " + e.getMessage());
            }
        } else if (value instanceof Long) {
            // Longs are assumed to be java time (millis since epoch).
            return new Date((Long) value);
        } else if (value instanceof Integer) {
            // Integers are assumed to be unix time (seconds since epoch).
            return new Date(((Integer) value).longValue() * 1000L);
        } else {
            throw new IncompatibleValueException("Unable to convert " + value.getClass().getSimpleName() + " to a date");
        }
    }
945929
private function createDateTime($value)
    {
        if ($value instanceof DateTime) {
            return $value;
        }
        if ($value instanceof \MongoDate) {
            $dateStr = date('Y-m-d H:i:s.'.$value->usec, $value->sec);
            return new DateTime($dateStr);
        }
        if (is_numeric($value)) {
            // Supports microseconds
            $value = (Float) $value;
            $usec = round(($value - (Integer) $value) * 1000000, 0);
            $dateStr = date('Y-m-d H:i:s.'.$usec, (Integer) $value);
            return new DateTime($dateStr);
        }
        return new DateTime((String) $value);
    }
450685
def make_id(value):
    
    if isinstance(value, six.string_types):
        value = value.encode("utf8", "ignore")
    from hashlib import md5

    val = uuid.UUID(bytes=md5(value).digest(), version=4)

    return base64.urlsafe_b64encode(val.get_bytes())[:-2]
634514
def validate_uuid(value):
    

    if value and not isinstance(value, UUID):
        try:
            return UUID(str(value), version=4)
        except (AttributeError, ValueError):
            raise ValidationError('not a valid UUID')
    return value
501446
public static UUID getNext(UUID uuid) {
        checkArgument(uuid.version() == 1, "Not a time UUID");
        UUID max = maximumUuid();
        long lsb = uuid.getLeastSignificantBits();
        if (lsb < max.getLeastSignificantBits()) {
            return new UUID(uuid.getMostSignificantBits(), lsb + 1);
        }
        long timestamp = uuid.timestamp();
        if (timestamp < max.timestamp()) {
            return new UUID(getMostSignificantBits(timestamp + 1), minimumUuid().getLeastSignificantBits());
        }
        return null;  // No next exists since uuid == maximumUuid()
    }
842433
public function setCreationTimestamp(\AgentSIB\Diadoc\Api\Proto\Timestamp $value = null)
    {
        $this->CreationTimestamp = $value;
    }
974527
def uuid(self, value):
        """"""
        if value is not None:
            self.keystore['id'] = value
        elif 'id' in self.keystore:
            self.keystore.pop('id')
764655
public static function createUUID()
    {
        return self::create(
                sprintf(
                    '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
                    // 32 bits for "time_low"
                    mt_rand(0, 0xffff), mt_rand(0, 0xffff),
                    // 16 bits for "time_mid"
                                                mt_rand(0, 0xffff),
                    // 16 bits for "time_hi_and_version",
                    // four most significant bits holds version number 4
                                                        mt_rand(0, 0x0fff) | 0x4000,
                    // 16 bits, 8 bits for "clk_seq_hi_res",
                    // 8 bits for "clk_seq_low",
                    // two most significant bits holds zero and one for variant DCE1.1
                                                                mt_rand(0, 0x3fff) | 0x8000,
                    // 48 bits for "node"
                                                                        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
                )
        );
    }
6902
def insert(self, value):
        ""
        key = str(uuid4())
        self.set(key, value)
        return key
460181
public static V1Annotation create(long timestamp, String value, @Nullable Endpoint endpoint) {
    return new V1Annotation(timestamp, value, endpoint);
  }
1344932
def serialize(value)
      return if value.nil?
      undashed_uuid = strip_dashes(value)

      # To avoid SQL injection, verify that it looks like a UUID. ActiveRecord
      # does not explicity escape the Binary data type. escaping is implicit as
      # the Binary data type always converts its value to a hex string.
      unless valid_undashed_uuid?(undashed_uuid)
        raise MySQLBinUUID::InvalidUUID, "#{value} is not a valid UUID"
      end

      Data.new(undashed_uuid)
    end
1083955
private function uuidTextToBin($value)
	{
		// Multiple files
		if (substr($value, 0, 2) === 'a:') {
			return serialize(array_map(function($value) {
				if (strlen($value) === 36) {
					$value = \StringUtil::uuidToBin($value);
				}
				return $value;
			}, \StringUtil::deserialize($value)));
		}
		// Single file
		if (strlen($value) === 36) {
			return \StringUtil::uuidToBin($value);
		}

		return $value;
	}