2011-07-14 7 views
3

私はUUID v1をキーとするデータを格納しています。これで、UUIDの生成時期を知りたいと思います。どうやっていいの?ルビのUUID v1からの抽出時間

+0

これはpythonでどのように行われているのですか?http://stackoverflow.com/questions/3795554/extract-the-time-from-a-uuid-v1-in-python多分テンプレートとして使うことができます。 –

+0

Pythonで[この小さなレシピ](http://code.activestate.com/recipes/576420-get-a-posix-timestamp-from-a-type-1-uuid/)が見つかりました。私はRubyがうまくないので、誰かがRubyのためにこれを作れますか? – mhk

答えて

2

これはIRBで動作します。私の友人KillerFoxへ

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 

おかげで、彼は私に簡単な解決策を示しました。

関連する問題