[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * BENNU - PHP iCalendar library 5 * (c) 2005-2006 Ioannis Papaioannou ([email protected]). All rights reserved. 6 * 7 * Released under the LGPL. 8 * 9 * See http://bennu.sourceforge.net/ for more information and downloads. 10 * 11 * @author Ioannis Papaioannou 12 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License 13 */ 14 15 class Bennu { 16 static function timestamp_to_datetime($t = NULL) { 17 if($t === NULL) { 18 $t = time(); 19 } 20 return gmstrftime('%Y%m%dT%H%M%SZ', $t); 21 } 22 23 static function generate_guid() { 24 // Implemented as per the Network Working Group draft on UUIDs and GUIDs 25 26 // These two octets get special treatment 27 $time_hi_and_version = sprintf('%02x', (1 << 6) + mt_rand(0, 15)); // 0100 plus 4 random bits 28 $clock_seq_hi_and_reserved = sprintf('%02x', (1 << 7) + mt_rand(0, 63)); // 10 plus 6 random bits 29 30 // Need another 14 random octects 31 $pool = ''; 32 for($i = 0; $i < 7; ++$i) { 33 $pool .= sprintf('%04x', mt_rand(0, 65535)); 34 } 35 36 // time_low = 4 octets 37 $random = substr($pool, 0, 8).'-'; 38 39 // time_mid = 2 octets 40 $random .= substr($pool, 8, 4).'-'; 41 42 // time_high_and_version = 2 octets 43 $random .= $time_hi_and_version.substr($pool, 12, 2).'-'; 44 45 // clock_seq_high_and_reserved = 1 octet 46 $random .= $clock_seq_hi_and_reserved; 47 48 // clock_seq_low = 1 octet 49 $random .= substr($pool, 13, 2).'-'; 50 51 // node = 6 octets 52 $random .= substr($pool, 14, 12); 53 54 return $random; 55 } 56 } 57
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |