/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/general/timeraw.inc
ViewVC logotype

Annotation of /to_be_filed/webprojs/php_libraries/php_library/general/timeraw.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (hide annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (8 years, 1 month ago) by dashley
File size: 2502 byte(s)
Initial commit.
1 dashley 35 <?php
2     //********************************************************************************
3     //Copyright (C) 2006 David T. Ashley
4     //********************************************************************************
5     //This program or source file is free software; you can redistribute it and/or
6     //modify it under the terms of the GNU General Public License as published by
7     //the Free Software Foundation; either version 2 of the License, or (at your
8     //option) any later version.
9     //
10     //This program or source file is distributed in the hope that it will
11     //be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12     //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     //GNU General Public License for more details.
14     //
15     //You may have received a copy of the GNU General Public License
16     //along with this program; if not, write to the Free Software
17     //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18     //********************************************************************************
19     //Dave Ashley, 01/06
20     //
21     //This source file provides raw time related code. This file is a wrapper
22     //around the built-in PHP functions to provide more flexibility as we get
23     //near the Unix epoch.
24     //
25     //Returns the time as 18 hexadecimal digits (using upper-case letters). The
26     //first 10 characters are the integer time, and the remaining 8 are
27     //the fractional time in nanoseconds.
28     //
29     function TIMERAW_time_precision_hex()
30     {
31     //Get the microseconds and seconds.
32     list($usec, $sec) = explode(" ", microtime());
33    
34     //Convert the microseconds to an integer giving the
35     //integer number of microseconds. The original value is in fractional
36     //seconds (a float).
37     $usec = $usec * 1000000.0;
38     $usec = (int) $usec;
39    
40     //Convert microseconds to nanoseconds.
41     $nsec = $usec * 1000;
42    
43     //Obtain a string of length 10 hex characters representing the integer
44     //time. The first 2 characters are always "00" at the present time (until
45     //Unix systems hit more than 32 bits for integers).
46     $sec_string = "00" . sprintf("%08X", $sec);
47    
48     //Obtain a string of length 8 hex characters representing the fractional
49     //time.
50     $nsec_string = sprintf("%08X", $nsec);
51    
52     //The returned value is the concatenation.
53     return($sec_string . $nsec_string);
54     }
55    
56     //Return the size (in chars) of a precision timestamp expressed in hex.
57     //
58     function TIMERAW_time_precision_hex_size()
59     {
60     return(18);
61     }
62     ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25