phpcassa
phpcassa copied to clipboard
v1 UUID incorrect
v1 UUID incorrect
With time: '2012-06-06 00:00:00' 'America/Los_Angeles'
With phpcassa I get: 31973f60-1dd5-11b2-888f-4d43d6cc3201
With pycassa I get: 3b77d800-afa5-11e1-8080-808080808080
The first half is way off. The second half doesn't matter but would be nice to set low, high, or random.
I did a quick check and the times match on both:
require_once(__DIR__.'/../lib/autoload.php');
use phpcassa\Util\Clock;
use phpcassa\UUID;
$t = Clock::get_time();
echo "time: $t\n";
$u = UUID::uuid1(null, $t);
echo "uuid: $u\n";
echo "uuid time: $u->time\n";
copying the uuid string from the php script:
from pycassa.util import convert_uuid_to_time
from uuid import UUID
u = UUID('5446a860-7f84-11e2-9e94-49f48a45be67')
print "time:", convert_uuid_to_time(u)
The times match to within 100 microseconds.
How are you supplying the time to the UUID::uuid1()
function in php?
Awww I see what you did with the Clock::get_time(), but the problem with this is then I can't import a time. I need to set a specific time, the "current" time is not useful to me.
I still need the Low, High, and Rand versions for the v1 UUID. I created a work around right now but would need this if I was going to use the UUID class fully.
Awww I see what you did with the Clock::get_time(), but the problem with this is then I can't import a time. I need to set a specific time, the "current" time is not useful to me.
You just need to provide an integer timestamp that is the number of microseconds since the unix epoch. For example, if the current time is 1361898056.292402, the timestamp will be 1361898056292402.
I still need the Low, High, and Rand versions for the v1 UUID. I created a work around right now but would need this if I was going to use the UUID class fully.
I'll see if I can port the pycassa logic for this to php.