Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting time from v1 uuid #49

Closed
wants to merge 1 commit into from
Closed

Conversation

krassif
Copy link

@krassif krassif commented Sep 11, 2012

Added a method to extract msecs from v1 type uuid. I saw uuidjs had low/high time, but it would be better if everything was in a single, well performing library.

@booo
Copy link

booo commented Dec 28, 2012

Any plans to merge this?

@broofa
Copy link
Member

broofa commented Dec 29, 2012

Sorry for not responding earlier - I'm afraid this fell off my radar. (Feel free to harass me if you don't feel I'm responding fast enough in the future, btw)

There's been more than one request for the ability to parse fields out of UUIDs, and this obviously fits in nicely with that. However my suspicion is that a relatively small %'age of the people generating IDs need a parsing feature. Thus, I'm a little reluctant to add this as part of the core module.

Ideally I'd like to break this code apart such that people who only need to generate v4 UUIDs can do so without incurring the code bloat that goes along with v1 generation and parsing. If anyone has ideas on the best way to do that I'd love to hear them. For my part, I'm thinking this may take the form of separate modules for:

  • uuid-v4 - code for generating v4 UUIDs
  • uuid-v1 - code for generating v1 UUIDs
  • uuid-parse - utility functions for parsing RFC4122 fields

... and have a build script of some sort that compiles these together into a single uuid.js file. This way people can (for example) only use the uuid-v4 module if they don't want/need the code necessary for supporting v1 generation and parsing.

Anyhow... my point is that I see this as version 2 functionality. Thoughts?

@jonathanrdelgado
Copy link

Major +1 to merge.

Props to you, @krassif.

@obenjiro
Copy link

+1 this is really useful thing to add.. plz add this if possible

@ronkorving
Copy link

big +1
@broofa I appreciate the bigger plan here, but for now, nothing is happening at all and people need this. So how about we iterate small now, and perhaps later release a v2 where your suggestion can become a reality?

@sgronblo
Copy link

sgronblo commented Nov 8, 2013

Yes this would seem to be useful for Cassandra users where you can combine a row's created_at timestamp with the row's id. But when you display the row you will have to be able to extract the timestamp from the time uuid. As long as the pull request is correct I support a merge.

I think the package is still far from being bloated. And won't the performance conscious users who use this package in a low spec mobile browser optimize out the v1 functions when minimizing their JS code anyway?

Also, @ronkorving 久しぶりです

@petetronic
Copy link

This seems like a useful feature for v1 uuids to warrant inclusion.

@somecallmemike
Copy link

I went ahead and patched this myself and it works splendidly. Broofa, this is way too useful not to incorporate as people need to convert both directions. +1 and a half.

@ronkorving
Copy link

It's only been 2 years now. Still within reason to discuss architecture ;) Get this in already please.

@gwicke
Copy link

gwicke commented Sep 29, 2014

+1 from me as well.

@somecallmemike
Copy link

Is this going to be patched anytime soon?

@indexzero
Copy link

FWIW, 👍 from me as well. I will bother @broofa over email since he said I should 😄

@indexzero
Copy link

But unfortunately, this does not work ...

v1time(uuid.v1());
Error: uuid version 1 expected

@indexzero
Copy link

Sorry I was mistaken, it does work, but imho the above API is important to have working. The correct way to use this in it's current form is:

v1time(uuid.parse(uuid.v1()));

@indexzero
Copy link

FYI I ripped this out into a module. Thanks @krassif for writing it. I attributed you in the README and also implemented optional parsing from strings. https://github.com/indexzero/uuid-time

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

Successfully merging this pull request may close these issues.

None yet