858,6 → 858,14 |
$milliseconds = round($millisecond8bits / 255 * 999); |
$seconds = hexdec(substr($uuid,6,2)); |
// Verbose info |
$utc_time = |
str_pad("$year",4,'0',STR_PAD_LEFT).'-'. |
str_pad("$month",2,'0',STR_PAD_LEFT).'-'. |
str_pad("$day",2,'0',STR_PAD_LEFT).' '. |
str_pad("$hours",2,'0',STR_PAD_LEFT).':'. |
str_pad("$minutes",2,'0',STR_PAD_LEFT).':'. |
str_pad("$seconds",2,'0',STR_PAD_LEFT)."'". |
str_pad("$milliseconds",2,'0',STR_PAD_LEFT); |
echo "\n<u>Interpretation of <a href=\"https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25\">HickelSOFT \"SQL Server Sortable Custom UUID\", Version 2</a></u>\n\n"; |
echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad("".base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT)); |
echo sprintf("%-32s %s\n", "Milliseconds:", "[0x".substr($uuid,4,2)."] $milliseconds"); |
867,16 → 875,7 |
echo sprintf("%-32s %s\n", "Random 2 bits:", "[$rnd2bits] 0b".str_pad("".base_convert("$rnd2bits", 16, 2), 2, '0', STR_PAD_LEFT)); |
echo sprintf("%-32s %s\n", "Year:", "[0x".substr($uuid,17,3)."] $year)"); |
echo sprintf("%-32s %s\n", "Signature:", "[0x".substr($uuid,20,12)."] HICKEL"); |
echo sprintf("%-32s %s\n", "UTC Date Time:", |
str_pad("$year",4,'0',STR_PAD_LEFT).'-'. |
str_pad("$month",2,'0',STR_PAD_LEFT).'-'. |
str_pad("$day",2,'0',STR_PAD_LEFT).' '. |
str_pad("$hours",2,'0',STR_PAD_LEFT).':'. |
str_pad("$minutes",2,'0',STR_PAD_LEFT).':'. |
str_pad("$seconds",2,'0',STR_PAD_LEFT)."'". |
str_pad("$milliseconds",2,'0',STR_PAD_LEFT) |
); |
echo sprintf("%-32s %s\n", "Implementation:", "https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25"); |
echo sprintf("%-32s %s\n", "UTC Date Time:", $utc_time); |
} else if (strtolower($signature) == '000000000000') { |
// HickelSOFT "SQL Server sortable UUID in C#" |
// Version 1: Resolution of 1 milliseconds, random part of 16 bits, local timezone, NOT UUIDv8 conform. |
901,17 → 900,7 |
$seconds = substr($uuid,6,2); |
if (!is_numeric($seconds) || ($seconds < 0) || ($seconds >= 60)) $seconds = 'XX'; else $seconds = intval($seconds); |
// Verbose info |
echo "\n<u>Interpretation of <a href=\"https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25\">HickelSOFT \"SQL Server Sortable Custom UUID\", Version 1</a></u>\n\n"; |
echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad(base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT)); |
echo sprintf("%-32s %s\n", "Milliseconds:", "[0x".substr($uuid,4,2)."] $milliseconds"); |
echo sprintf("%-32s %s\n", "Seconds:", "[0x".substr($uuid,6,2)."] $seconds"); |
echo sprintf("%-32s %s\n", "Minutes:", "[0x".substr($uuid,8,2)."] $minutes"); |
echo sprintf("%-32s %s\n", "Hours:", "[0x".substr($uuid,10,2)."] $hours"); |
echo sprintf("%-32s %s\n", "Day:", "[0x".substr($uuid,12,2)."] $day"); |
echo sprintf("%-32s %s\n", "Month:", "[0x".substr($uuid,14,2)."] $month"); |
echo sprintf("%-32s %s\n", "Year:", "[0x".substr($uuid,16,4)."] $year"); |
echo sprintf("%-32s %s\n", "Signature:", "[0x".substr($uuid,20,12)."]"); |
echo sprintf("%-32s %s\n", "Generator's Local Date Time:", |
$local_time = |
str_pad("$year",4,'0',STR_PAD_LEFT).'-'. |
str_pad("$month",2,'0',STR_PAD_LEFT).'-'. |
str_pad("$day",2,'0',STR_PAD_LEFT).' '. |
918,9 → 907,20 |
str_pad("$hours",2,'0',STR_PAD_LEFT).':'. |
str_pad("$minutes",2,'0',STR_PAD_LEFT).':'. |
str_pad("$seconds",2,'0',STR_PAD_LEFT)."'". |
str_pad("$milliseconds",2,'0',STR_PAD_LEFT) |
); |
echo sprintf("%-32s %s\n", "Implementation:", "https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25"); |
str_pad("$milliseconds",2,'0',STR_PAD_LEFT); |
if (strpos($local_time,'X') === false) { |
echo "\n<u>Interpretation of <a href=\"https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25\">HickelSOFT \"SQL Server Sortable Custom UUID\", Version 1</a></u>\n\n"; |
echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad(base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT)); |
echo sprintf("%-32s %s\n", "Milliseconds:", "[0x".substr($uuid,4,2)."] $milliseconds"); |
echo sprintf("%-32s %s\n", "Seconds:", "[0x".substr($uuid,6,2)."] $seconds"); |
echo sprintf("%-32s %s\n", "Minutes:", "[0x".substr($uuid,8,2)."] $minutes"); |
echo sprintf("%-32s %s\n", "Hours:", "[0x".substr($uuid,10,2)."] $hours"); |
echo sprintf("%-32s %s\n", "Day:", "[0x".substr($uuid,12,2)."] $day"); |
echo sprintf("%-32s %s\n", "Month:", "[0x".substr($uuid,14,2)."] $month"); |
echo sprintf("%-32s %s\n", "Year:", "[0x".substr($uuid,16,4)."] $year"); |
echo sprintf("%-32s %s\n", "Signature:", "[0x".substr($uuid,20,12)."]"); |
echo sprintf("%-32s %s\n", "Generator's Local Date Time:", $local_time); |
} |
} |
|
// END: HickelSOFT UUID |