Rev 79 | Rev 81 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 79 | Rev 80 | ||
---|---|---|---|
Line 856... | Line 856... | ||
856 | $rnd16bits = substr($uuid,0,4); |
856 | $rnd16bits = substr($uuid,0,4); |
857 | $millisecond8bits = hexdec(substr($uuid,4,2)); |
857 | $millisecond8bits = hexdec(substr($uuid,4,2)); |
858 | $milliseconds = round($millisecond8bits / 255 * 999); |
858 | $milliseconds = round($millisecond8bits / 255 * 999); |
859 | $seconds = hexdec(substr($uuid,6,2)); |
859 | $seconds = hexdec(substr($uuid,6,2)); |
860 | // Verbose info |
860 | // Verbose info |
- | 861 | $utc_time = |
|
- | 862 | str_pad("$year",4,'0',STR_PAD_LEFT).'-'. |
|
- | 863 | str_pad("$month",2,'0',STR_PAD_LEFT).'-'. |
|
- | 864 | str_pad("$day",2,'0',STR_PAD_LEFT).' '. |
|
- | 865 | str_pad("$hours",2,'0',STR_PAD_LEFT).':'. |
|
- | 866 | str_pad("$minutes",2,'0',STR_PAD_LEFT).':'. |
|
- | 867 | str_pad("$seconds",2,'0',STR_PAD_LEFT)."'". |
|
- | 868 | str_pad("$milliseconds",2,'0',STR_PAD_LEFT); |
|
861 | 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"; |
869 | 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"; |
862 | echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad("".base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT)); |
870 | echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad("".base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT)); |
863 | echo sprintf("%-32s %s\n", "Milliseconds:", "[0x".substr($uuid,4,2)."] $milliseconds"); |
871 | echo sprintf("%-32s %s\n", "Milliseconds:", "[0x".substr($uuid,4,2)."] $milliseconds"); |
864 | echo sprintf("%-32s %s\n", "Seconds:", "[0x".substr($uuid,6,2)."] $seconds"); |
872 | echo sprintf("%-32s %s\n", "Seconds:", "[0x".substr($uuid,6,2)."] $seconds"); |
865 | echo sprintf("%-32s %s\n", "Minute of day:", "[0x".substr($uuid,8,4)."] $minuteOfDay (".str_pad("$hours",2,'0',STR_PAD_LEFT).":".str_pad("$minutes",2,'0',STR_PAD_LEFT).")"); |
873 | echo sprintf("%-32s %s\n", "Minute of day:", "[0x".substr($uuid,8,4)."] $minuteOfDay (".str_pad("$hours",2,'0',STR_PAD_LEFT).":".str_pad("$minutes",2,'0',STR_PAD_LEFT).")"); |
866 | echo sprintf("%-32s %s\n", "Day of year:", "[0x".substr($uuid,13,3)."] $dayOfYear (Day=$day, Month=$month)"); |
874 | echo sprintf("%-32s %s\n", "Day of year:", "[0x".substr($uuid,13,3)."] $dayOfYear (Day=$day, Month=$month)"); |
867 | echo sprintf("%-32s %s\n", "Random 2 bits:", "[$rnd2bits] 0b".str_pad("".base_convert("$rnd2bits", 16, 2), 2, '0', STR_PAD_LEFT)); |
875 | echo sprintf("%-32s %s\n", "Random 2 bits:", "[$rnd2bits] 0b".str_pad("".base_convert("$rnd2bits", 16, 2), 2, '0', STR_PAD_LEFT)); |
868 | echo sprintf("%-32s %s\n", "Year:", "[0x".substr($uuid,17,3)."] $year)"); |
876 | echo sprintf("%-32s %s\n", "Year:", "[0x".substr($uuid,17,3)."] $year)"); |
869 | echo sprintf("%-32s %s\n", "Signature:", "[0x".substr($uuid,20,12)."] HICKEL"); |
877 | echo sprintf("%-32s %s\n", "Signature:", "[0x".substr($uuid,20,12)."] HICKEL"); |
870 | echo sprintf("%-32s %s\n", "UTC Date Time:", |
878 | echo sprintf("%-32s %s\n", "UTC Date Time:", $utc_time); |
871 | str_pad("$year",4,'0',STR_PAD_LEFT).'-'. |
- | |
872 | str_pad("$month",2,'0',STR_PAD_LEFT).'-'. |
- | |
873 | str_pad("$day",2,'0',STR_PAD_LEFT).' '. |
- | |
874 | str_pad("$hours",2,'0',STR_PAD_LEFT).':'. |
- | |
875 | str_pad("$minutes",2,'0',STR_PAD_LEFT).':'. |
- | |
876 | str_pad("$seconds",2,'0',STR_PAD_LEFT)."'". |
- | |
877 | str_pad("$milliseconds",2,'0',STR_PAD_LEFT) |
- | |
878 | ); |
- | |
879 | echo sprintf("%-32s %s\n", "Implementation:", "https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25"); |
- | |
880 | } else if (strtolower($signature) == '000000000000') { |
879 | } else if (strtolower($signature) == '000000000000') { |
881 | // HickelSOFT "SQL Server sortable UUID in C#" |
880 | // HickelSOFT "SQL Server sortable UUID in C#" |
882 | // Version 1: Resolution of 1 milliseconds, random part of 16 bits, local timezone, NOT UUIDv8 conform. |
881 | // Version 1: Resolution of 1 milliseconds, random part of 16 bits, local timezone, NOT UUIDv8 conform. |
883 | // Example: ff38da51-1301-0903-2420-000000000000 |
882 | // Example: ff38da51-1301-0903-2420-000000000000 |
884 | // Block 4 |
883 | // Block 4 |
Line 899... | Line 898... | ||
899 | $millisecond8bits = hexdec(substr($uuid,4,2)); |
898 | $millisecond8bits = hexdec(substr($uuid,4,2)); |
900 | $milliseconds = round($millisecond8bits / 255 * 999); |
899 | $milliseconds = round($millisecond8bits / 255 * 999); |
901 | $seconds = substr($uuid,6,2); |
900 | $seconds = substr($uuid,6,2); |
902 | if (!is_numeric($seconds) || ($seconds < 0) || ($seconds >= 60)) $seconds = 'XX'; else $seconds = intval($seconds); |
901 | if (!is_numeric($seconds) || ($seconds < 0) || ($seconds >= 60)) $seconds = 'XX'; else $seconds = intval($seconds); |
903 | // Verbose info |
902 | // Verbose info |
- | 903 | $local_time = |
|
- | 904 | str_pad("$year",4,'0',STR_PAD_LEFT).'-'. |
|
- | 905 | str_pad("$month",2,'0',STR_PAD_LEFT).'-'. |
|
- | 906 | str_pad("$day",2,'0',STR_PAD_LEFT).' '. |
|
- | 907 | str_pad("$hours",2,'0',STR_PAD_LEFT).':'. |
|
- | 908 | str_pad("$minutes",2,'0',STR_PAD_LEFT).':'. |
|
- | 909 | str_pad("$seconds",2,'0',STR_PAD_LEFT)."'". |
|
- | 910 | str_pad("$milliseconds",2,'0',STR_PAD_LEFT); |
|
- | 911 | if (strpos($local_time,'X') === false) { |
|
904 | 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"; |
912 | 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"; |
905 | echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad(base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT)); |
913 | echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad(base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT)); |
906 | echo sprintf("%-32s %s\n", "Milliseconds:", "[0x".substr($uuid,4,2)."] $milliseconds"); |
914 | echo sprintf("%-32s %s\n", "Milliseconds:", "[0x".substr($uuid,4,2)."] $milliseconds"); |
907 | echo sprintf("%-32s %s\n", "Seconds:", "[0x".substr($uuid,6,2)."] $seconds"); |
915 | echo sprintf("%-32s %s\n", "Seconds:", "[0x".substr($uuid,6,2)."] $seconds"); |
908 | echo sprintf("%-32s %s\n", "Minutes:", "[0x".substr($uuid,8,2)."] $minutes"); |
916 | echo sprintf("%-32s %s\n", "Minutes:", "[0x".substr($uuid,8,2)."] $minutes"); |
909 | echo sprintf("%-32s %s\n", "Hours:", "[0x".substr($uuid,10,2)."] $hours"); |
917 | echo sprintf("%-32s %s\n", "Hours:", "[0x".substr($uuid,10,2)."] $hours"); |
910 | echo sprintf("%-32s %s\n", "Day:", "[0x".substr($uuid,12,2)."] $day"); |
918 | echo sprintf("%-32s %s\n", "Day:", "[0x".substr($uuid,12,2)."] $day"); |
911 | echo sprintf("%-32s %s\n", "Month:", "[0x".substr($uuid,14,2)."] $month"); |
919 | echo sprintf("%-32s %s\n", "Month:", "[0x".substr($uuid,14,2)."] $month"); |
912 | echo sprintf("%-32s %s\n", "Year:", "[0x".substr($uuid,16,4)."] $year"); |
920 | echo sprintf("%-32s %s\n", "Year:", "[0x".substr($uuid,16,4)."] $year"); |
913 | echo sprintf("%-32s %s\n", "Signature:", "[0x".substr($uuid,20,12)."]"); |
921 | echo sprintf("%-32s %s\n", "Signature:", "[0x".substr($uuid,20,12)."]"); |
914 | echo sprintf("%-32s %s\n", "Generator's Local Date Time:", |
922 | echo sprintf("%-32s %s\n", "Generator's Local Date Time:", $local_time); |
915 | str_pad("$year",4,'0',STR_PAD_LEFT).'-'. |
- | |
916 | str_pad("$month",2,'0',STR_PAD_LEFT).'-'. |
- | |
917 | str_pad("$day",2,'0',STR_PAD_LEFT).' '. |
- | |
918 | str_pad("$hours",2,'0',STR_PAD_LEFT).':'. |
- | |
919 | str_pad("$minutes",2,'0',STR_PAD_LEFT).':'. |
- | |
920 | str_pad("$seconds",2,'0',STR_PAD_LEFT)."'". |
- | |
921 | str_pad("$milliseconds",2,'0',STR_PAD_LEFT) |
- | |
922 | ); |
923 | } |
923 | echo sprintf("%-32s %s\n", "Implementation:", "https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25"); |
- | |
924 | } |
924 | } |
925 | 925 | ||
926 | // END: HickelSOFT UUID |
926 | // END: HickelSOFT UUID |
927 | 927 | ||
928 | if (!$echo) { |
928 | if (!$echo) { |