问题
I have stored data that has a UUID v1 as key and I now want to know when the UUID was generated. How do I do that the nice way?
回答1:
This works with irb:
require 'simple_uuid'
uuid = SimpleUUID::UUID.new
uuid.to_guid # actually this is what I have stored in my database
Time.at(SimpleUUID::UUID.new(uuid.to_guid).seconds) # returns the time and date of the UUID
Thanks to my friend KillerFox, he showed me the simple solution.
来源:https://stackoverflow.com/questions/6696518/extract-time-from-a-uuid-v1-in-ruby