File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -325,15 +325,14 @@ public struct UUID
325325 */
326326 @safe pure this (SysTime timestamp, ubyte [10 ] random = generateV7RandomData())
327327 {
328- ulong epoch = (timestamp - SysTime.fromUnixTime(0 )).total! " msecs" ;
329- this .data[6 .. $] = random[];
330-
331- this .data[0 ] = cast (ubyte )((epoch >> 40 ) & 0xFF );
332- this .data[1 ] = cast (ubyte )((epoch >> 32 ) & 0xFF );
333- this .data[2 ] = cast (ubyte )((epoch >> 24 ) & 0xFF );
334- this .data[3 ] = cast (ubyte )((epoch >> 16 ) & 0xFF );
335- this .data[4 ] = cast (ubyte )((epoch >> 8 ) & 0xFF );
336- this .data[5 ] = cast (ubyte )(epoch & 0xFF );
328+ import std.bitmanip : nativeToBigEndian;
329+
330+ ubyte [8 ] epoch = (timestamp - SysTime.fromUnixTime(0 ))
331+ .total! " msecs"
332+ .nativeToBigEndian;
333+
334+ this .data[0 .. 6 ] = epoch[2 .. 8 ];
335+ this .data[6 .. $] = random;
337336
338337 // version and variant
339338 this .data[6 ] = (this .data[6 ] & 0x0F ) | 0x70 ;
You can’t perform that action at this time.
0 commit comments