Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/bennu/bennu.class.php
Go to the documentation of this file.
00001 <?php
00002 
00015 class Bennu {
00016     function timestamp_to_datetime($t = NULL) {
00017         if($t === NULL) {
00018             $t = time();
00019         }
00020         return gmstrftime('%Y%m%dT%H%M%SZ', $t);
00021     }
00022 
00023     function generate_guid() {
00024         // Implemented as per the Network Working Group draft on UUIDs and GUIDs
00025     
00026         // These two octets get special treatment
00027         $time_hi_and_version       = sprintf('%02x', (1 << 6) + mt_rand(0, 15)); // 0100 plus 4 random bits
00028         $clock_seq_hi_and_reserved = sprintf('%02x', (1 << 7) + mt_rand(0, 63)); // 10 plus 6 random bits
00029     
00030         // Need another 14 random octects
00031         $pool = '';
00032         for($i = 0; $i < 7; ++$i) {
00033             $pool .= sprintf('%04x', mt_rand(0, 65535));
00034         }
00035     
00036         // time_low = 4 octets
00037         $random  = substr($pool, 0, 8).'-';
00038     
00039         // time_mid = 2 octets
00040         $random .= substr($pool, 8, 4).'-';
00041     
00042         // time_high_and_version = 2 octets
00043         $random .= $time_hi_and_version.substr($pool, 12, 2).'-';
00044     
00045         // clock_seq_high_and_reserved = 1 octet
00046         $random .= $clock_seq_hi_and_reserved;
00047     
00048         // clock_seq_low = 1 octet
00049         $random .= substr($pool, 13, 2).'-';
00050     
00051         // node = 6 octets
00052         $random .= substr($pool, 14, 12);
00053     
00054         return $random;
00055     }
00056 }
00057 
 All Data Structures Namespaces Files Functions Variables Enumerations