/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/fboprime/utimex.inc
ViewVC logotype

Annotation of /to_be_filed/webprojs/php_libraries/php_library/fboprime/utimex.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (hide annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (7 years, 10 months ago) by dashley
File size: 4081 byte(s)
Initial commit.
1 dashley 35 <?php
2     //$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/phplib/utimex.inc,v 1.3 2006/09/25 21:11:28 dashley Exp $
3     //
4     //utimex.inc--UTIME-related functions that are not needed by the dayview
5     // scheduler.
6     //********************************************************************************
7     //Copyright (C)2006 David T. Ashley
8     //********************************************************************************
9     //This program or source file is free software; you can redistribute it and/or
10     //modify it under the terms of the GNU General Public License as published by
11     //the Free Software Foundation; either version 2 of the License, or (at your
12     //option) any later version.
13     //
14     //This program or source file is distributed in the hope that it will
15     //be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16     //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     //GNU General Public License for more details.
18     //
19     //You may have received a copy of the GNU General Public License
20     //along with this program; if not, write to the Free Software
21     //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22     //********************************************************************************
23     //Dave Ashley, 05/06
24     //
25     //This source file contains Unix time functions.
26     //
27     require_once("strfunc.inc"); //Necessary to left-zero pad string representations of integers
28     require_once("timeraw.inc"); //Raw time acquisition.
29     //
30     //--------------------------------------------------------------------------------
31     //Returns a UTIME corresponding to the time (in a coarse sense, meaning that
32     //fractional seconds are ignored) a certain integer number of seconds offset from
33     //The minimum and maximum values of the UTIME are used as the floor and ceiling
34     //limits of the result.
35     //
36     function UTIME_time_offset_coarse($ut_in, $offset_in)
37     {
38     //Extract the integer seconds string.
39     $int_secs_string = SubStr($ut_in, 2, 11);
40    
41     //Strip off any leading zeros.
42     while ((strlen($int_secs_string) > 1) && (SubStr($int_secs_string, 0, 1) == "0"))
43     $int_secs_string = SubStr($int_secs_string, 1);
44    
45     //Form an integer result that is offset from this integer by the passed
46     //value.
47     $offset_time = bcadd($int_secs_string, (string)$offset_in);
48    
49     //Apply the floor and ceiling.
50     if (bccomp($offset_time, "0") == -1)
51     {
52     //Result is below the Unix epoch. Apply floor.
53     //
54     return("UT00000000000000000000");
55     }
56     else if (bccomp($offset_time, "99999999999") == 1)
57     {
58     //Result is above the max value that can be represented. Apply ceiling.
59     //
60     return("UT99999999999000000000");
61     }
62     else
63     {
64     //Result is valid. Format the string and return.
65     $offset_time = (string)$offset_time;
66     //
67     $offset_time = STRFUNC_pad_left_zero($offset_time, 11);
68     return("UT" . $offset_time . "000000000");
69     }
70     }
71     //
72     //--------------------------------------------------------------------------------
73     //Reformats an UTIME string to include dots at strategic places for more
74     //human-friendly display.
75     //
76     function UTIME_dotted_display_string_a($utime_in)
77     {
78     if (! is_string($utime_in))
79     {
80     //Don't know what this is ... it isn't an utime. Just send it back.
81     return($utime_in);
82     }
83     else if (strlen($utime_in) != 22)
84     {
85     //This doesn't seem to be the right length for an utime. Give it back.
86     return($utime_in);
87     }
88     else
89     {
90     //Seems right.
91     return(
92     SubStr($utime_in, 0, 2)
93     .
94     "."
95     .
96     SubStr($utime_in, 2, 11)
97     .
98     "."
99     .
100     SubStr($utime_in, 13, 9)
101     );
102     }
103     }
104     //
105     //--------------------------------------------------------------------------------
106     //End of $RCSfile: utimex.inc,v $.
107     //--------------------------------------------------------------------------------
108     ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25