Eevans added a comment.

In https://phabricator.wikimedia.org/T116247#1749452, @Ottomata wrote:

> Right, but how would you do this in say, Hive?  Or in bash?


In bash:

  $ sudo apt-get install uuid
  $ ID=$(uuid -v 1)
  $ grep "content: time" <(uuid -d $ID)
      content: time:  2015-10-26 15:16:20.026434.0 UTC

In Java (applicable to Hive?):

  import java.util.Date;
  import java.util.UUID;
  
  public class Time {
      public static void main(String...args) {
          UUID id = UUID.fromString(args[0]);
          double timestamp = (id.timestamp() - 0x01b21dd213814000L)*100/1e6;
          System.out.println(new Date((long)timestamp));
      }
  }

Anyway, I don't object to including the redundant iso8601 timestamp, I just 
wanted to make sure it was clear that it's not at all difficult to extract a 
timestamp from a v1 UUID (and even less onerous when you figure that code like 
this would be tucked away in a helper somewhere).


TASK DETAIL
  https://phabricator.wikimedia.org/T116247

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Eevans
Cc: EBernhardson, Smalyshev, yuvipanda, Hardikj, daniel, aaron, GWicke, 
mobrovac, MZMcBride, bd808, JanZerebecki, Halfak, Krenair, brion, chasemp, 
Eevans, mmodell, Ottomata, Mattflaschen, Matanya, Aklapper, JAllemandou, 
jkroll, Wikidata-bugs, Jdouglas, aude, Deskana, Manybubbles, RobLa-WMF, jeremyb



_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to