Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

v1 UUID incorrect #121

Open
scottix opened this issue Feb 21, 2013 · 3 comments
Open

v1 UUID incorrect #121

scottix opened this issue Feb 21, 2013 · 3 comments

Comments

@scottix
Copy link

scottix commented Feb 21, 2013

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.

@thobbs
Copy link
Owner

thobbs commented Feb 25, 2013

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?

@scottix
Copy link
Author

scottix commented Feb 26, 2013

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.

@thobbs
Copy link
Owner

thobbs commented Feb 26, 2013

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants