CWIS Developer Documentation
Axis--Date.php
Go to the documentation of this file.
1 <?PHP
2 
3 #
4 # Axis--Date.php
5 # A Date Manipulation Object
6 #
7 # Copyright 1999-2004 Axis Data
8 # This code is free software that can be used or redistributed under the
9 # terms of Version 2 of the GNU General Public License, as published by the
10 # Free Software Foundation (http://www.fsf.org).
11 #
12 # Author: Edward Almasy (almasy@axisdata.com)
13 #
14 # Part of the AxisPHP library v1.2.5
15 # For more information see http://www.axisdata.com/AxisPHP/
16 #
17 
18 class Date {
19 
20  # ---- PUBLIC INTERFACE --------------------------------------------------
21 
22  # object constructor
23  function Date($BeginDate, $EndDate = NULL, $Precision = NULL, $DebugLevel = 0)
24  {
25  # set debug state
26  $this->DebugLevel = $DebugLevel;
27 
28  if ($this->DebugLevel) { print("Date: Date(BeginDate=\"".$BeginDate."\" EndDate=\"".$EndDate."\" Precision=".$this->FormattedPrecision($Precision).")<br>\n"); }
29 
30  $MonthNames = array(
31  "january" => 1,
32  "february" => 2,
33  "march" => 3,
34  "april" => 4,
35  "may" => 5,
36  "june" => 6,
37  "july" => 7,
38  "august" => 8,
39  "september" => 9,
40  "october" => 10,
41  "november" => 11,
42  "december" => 12,
43  "jan" => 1,
44  "feb" => 2,
45  "mar" => 3,
46  "apr" => 4,
47  "may" => 5,
48  "jun" => 6,
49  "jul" => 7,
50  "aug" => 8,
51  "sep" => 9,
52  "oct" => 10,
53  "nov" => 11,
54  "dec" => 12
55  );
56 
57  # Formats we need to parse:
58  # 1999-9-19
59  # 1999-9
60  # 9-19-1999
61  # 19-9-1999
62  # Sep-1999
63  # Sep 1999
64  # Sep 9 1999
65  # September 9, 1999
66  # September 9th, 1999
67  # 1996,1999
68  # c1999
69  # 1996-1999
70  # 9/19/01
71  # 9-19-01
72  # 199909
73  # 19990909
74  # 09-Sep-1999
75  # 09 Sep 1999
76 
77  # append end date to begin date if available
78  $Date = $BeginDate;
79  if ($EndDate!==NULL)
80  {
81  $Date .= " - ".$EndDate;
82  }
83 
84  # strip off any leading or trailing whitespace
85  $Date = trim($Date);
86 
87  # bail out if we don't have anything to parse
88  if (strlen($Date) < 1) { return; }
89 
90  # check for and strip out inferred indicators ("[" and "]")
91  $Prec = 0;
92  if (preg_match("/\\[/", $Date))
93  {
94  $Prec |= DATEPRE_INFERRED;
95  $Date = preg_replace("/[\\[\\]]/", "", $Date);
96  }
97 
98  # check for and strip off copyright indicator (leading "c")
99  if (preg_match("/^c/", $Date))
100  {
101  $Prec |= DATEPRE_COPYRIGHT;
102  $Date = preg_replace("/^c/", "", $Date);
103  }
104 
105  # check for and strip off continuous indicator (trailing "-")
106  if (preg_match("/\\-$/", $Date))
107  {
108  $Prec |= DATEPRE_CONTINUOUS;
109  $Date = preg_replace("/\\-$/", "", $Date);
110  }
111 
112  # strip out any times
113  $Date = preg_replace("/[0-9]{1,2}:[0-9]{2,2}[:]?[0-9]{0,2}/", "", $Date);
114  $Date = trim($Date);
115 
116  $Date = strtolower($Date);
117 
118  # A regex to match short and long month names:
119  $MonthRegex = "(?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may".
120  "|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:tember)?|oct(?:ober)?".
121  "|nov(?:ember)?|dec(?:ember)?)";
122 
123  # Here we'll construct a template regex for dates
124  # We want a single regex that covers all the different formats
125  # of date we understand, with the various components of the
126  # date pulled out using named subexpressions (eg: (?P<name>)).
127  # Annoyingly, we can't re-use the same name for subexpressions
128  # that will never both be matched at once.
129  # So, we have to number them (year1, year2, etc) and figure
130  # out which one did match.
131  # Use XX_ThingNumber in the parameterized subexpressions
132  # (eg XX_year1).
133  # We'll use string substitutions later to convert the XX_ to
134  # begin_ and end_
135 
136  $DateRegex = "(".
137  # Matched formats are separated by |, as this isn't used in any of the formats
138  # First alternative will match the following formats:
139  # 1999-09-19 | 19990909 | 1999-09 | 199909 | 1999
140  "(?:(?P<XX_year1>\d{4})(?:-?(?P<XX_month1>\d{1,2})(?:-?(?P<XX_day1>\d{1,2}))?)?)".
141  # Second alternative will match the following formats:
142  # 09-19-1999 | 19-09-1999 | 09/19/01 | 09-19-01
143  "|(?:(?P<XX_month2>\d{1,2})[\/-](?P<XX_day2>\d{1,2})[\/-](?P<XX_year2>(?:\d{2,4})))".
144  # Third alternative will match the following formats:
145  # 09-Sep-1999 | 09 Sep 1999 | Sep-1999 | Sep 1999
146  "|(?:(?:(?P<XX_day3>\d+)[ -])?(?P<XX_month3>".$MonthRegex.")[ -](?P<XX_year3>\d{4}))".
147  # Fourth alternative will match the following formats:
148  # Sep 9 1999 | September 9th, 1999
149  "|(?:(?P<XX_month4>".$MonthRegex.") (?P<XX_day4>\d{1,2})(?:(?:st|nd|rd|th|),)? (?P<XX_year4>\d{4}))".
150  ")";
151 
152  # If more formats are added, bump this.
153  $NumberOfDateRegexes = 4;
154 
155  # Construct the begin and end regexes for the date range
156  $BeginRegex = str_replace('XX','Begin', $DateRegex );
157  $EndRegex = str_replace('XX','End', $DateRegex );
158 
159  # Glue them together, making the second one optional,
160  # and do the matching.
161  if ( preg_match("/".$BeginRegex.
162  "(?:(?:(?: - )|,)".$EndRegex.")?/",
163  $Date, $Matches ) )
164  {
165  # Pull out the Begin and End data from the matches array:
166  foreach( array("Begin","End") as $Time )
167  {
168  eval(
169  # Extract the matching elements from the regex parse
170  '$'.$Time.'Day = $this->ExtractMatchData($Matches,"'.
171  $Time.'_day", $NumberOfDateRegexes );' .
172  '$'.$Time.'Month = $this->ExtractMatchData($Matches,"'.
173  $Time.'_month",$NumberOfDateRegexes );' .
174  '$'.$Time.'Year = $this->ExtractMatchData($Matches,"'.
175  $Time.'_year", $NumberOfDateRegexes );' .
176  # Convert named months to month numbers:
177  'if ( isset($'.$Time.'Month) && ' .
178  ' !is_numeric($'.$Time.'Month))' .
179  '{' .
180  ' $'.$Time.'Month=$MonthNames[$'.$Time.'Month];' .
181  '}' .
182  # Handle 2-digit years
183  'if ( isset($'.$Time.'Year) && ' .
184  ' strlen($'.$Time.'Year)==2)' .
185  '{' .
186  ' $'.$Time.'Year += ($'.$Time.'Year>50)?1900:2000;' .
187  '}' .
188  # Deal with D-M-Y format, where we can
189  'if ( isset($'.$Time.'Month) && $'.$Time.'Month>12)' .
190  '{' .
191  ' $Tmp = $'.$Time.'Month;' .
192  ' $'.$Time.'Month = $'.$Time.'Day;' .
193  ' $'.$Time.'Day = $Tmp;' .
194  '}'
195  );
196  }
197  }
198 
199  # use current month if begin day but no begin month specified
200  if (isset($BeginDay) && !isset($BeginMonth))
201  {
202  $BeginMonth = date("m");
203  }
204 
205  # use current year if begin month but no begin year specified
206  if (isset($BeginMonth) && !isset($BeginYear))
207  {
208  $BeginYear = date("Y");
209  }
210 
211  # use begin year if end month but no end year specified
212  if (isset($EndMonth) && !isset($EndYear))
213  {
214  $EndYear = $BeginYear;
215  }
216 
217  # After we've shuffled around the numbers, check the result to see if
218  # it looks valid, dropping that which doesn't.
219  foreach( array("Begin","End") as $Time)
220  {
221  eval(
222  # Discard invalid looking dates
223  'if ( isset($'.$Time.'Year) && !($'.$Time.'Year >=1)) ' .
224  ' { unset($'.$Time.'Year); } ' .
225  'if ( isset($'.$Time.'Month) && ' .
226  ' !( $'.$Time.'Month>=1 && $'.$Time.'Month<=12)) ' .
227  ' { unset($'.$Time.'Month); } ' .
228  'if ( isset($'.$Time.'Day) && ' .
229  ' !( $'.$Time.'Day >=1 && $'.$Time.'Day <=31)) ' .
230  ' { unset($'.$Time.'Day); } '
231  );
232  }
233 
234  # if no begin date found and begin date value is not illegal
235  if (!isset($BeginYear)
236  && ($BeginDate != "0000-00-00")
237  && ($BeginDate != "0000-00-00 00:00:00"))
238  {
239  # try system call to parse incoming date
240  $UDateStamp = strtotime($BeginDate);
241  if ($this->DebugLevel > 1) { print("Date: calling strtotime to parse BeginDate \"".$BeginDate."\" -- strtotime returned \"".$UDateStamp."\"<br>\n"); }
242 
243  # if system call was able to parse date
244  if (($UDateStamp != -1) && ($UDateStamp !== FALSE))
245  {
246  # set begin date to value returned by system call
247  $BeginYear = date("Y", $UDateStamp);
248  $BeginMonth = date("n", $UDateStamp);
249  $BeginDay = date("j", $UDateStamp);
250  }
251  }
252 
253  # if end date value supplied and no end date found and end date value is not illegal
254  if (($EndDate != NULL) && !isset($EndYear)
255  && ($EndDate != "0000-00-00")
256  && ($EndDate != "0000-00-00 00:00:00"))
257  {
258  # try system call to parse incoming date
259  $UDateStamp = strtotime($EndDate);
260 
261  # if system call was able to parse date
262  if (($UDateStamp != -1) && ($UDateStamp !== FALSE))
263  {
264  # set begin date to value returned by system call
265  $EndYear = date("Y", $UDateStamp);
266  $EndMonth = date("n", $UDateStamp);
267  $EndDay = date("j", $UDateStamp);
268  }
269  }
270 
271  # if end date is before begin date
272  if ((isset($EndYear) && isset($BeginYear) && ($EndYear < $BeginYear))
273  || (isset($BeginYear) && isset($EndYear) && ($EndYear == $BeginYear) &&
274  isset($BeginMonth) && isset($EndMonth) && ($EndMonth < $BeginMonth))
275  || (isset($BeginYear) && isset($EndYear) && ($EndYear == $BeginYear) &&
276  isset($BeginMonth) && isset($EndMonth) && ($EndMonth == $BeginMonth) &&
277  isset($BeginDay) && isset($EndDay) && ($EndDay < $BeginDay)))
278  {
279  # swap begin and end dates
280  $TempYear = $BeginYear;
281  $TempMonth = $BeginMonth;
282  $TempDay = $BeginDay;
285  $BeginDay = $EndDay;
286  $EndYear = $TempYear;
287  $EndMonth = $TempMonth;
288  $EndDay = $TempDay;
289  }
290 
291  # if precision value supplied by caller
292  if ($Precision != NULL)
293  {
294  # use supplied precision value
295  $this->Precision = $Precision;
296  }
297  else
298  {
299  # save new precision value
300  if (isset($BeginYear)) { $Prec |= DATEPRE_BEGINYEAR; }
301  if (isset($BeginMonth)) { $Prec |= DATEPRE_BEGINMONTH; }
302  if (isset($BeginDay)) { $Prec |= DATEPRE_BEGINDAY; }
303  if (isset($EndYear)) { $Prec |= DATEPRE_ENDYEAR; }
304  if (isset($EndMonth)) { $Prec |= DATEPRE_ENDMONTH; }
305  if (isset($EndDay)) { $Prec |= DATEPRE_ENDDAY; }
306  $this->Precision = $Prec;
307  }
308 
309  # save new date values
310  if ($this->DebugLevel > 1) { print("Date: BeginYear = $BeginYear<br>\n"); }
311  if ($this->DebugLevel > 1) { print("Date: BeginMonth = $BeginMonth<br>\n"); }
312  if ($this->DebugLevel > 1) { print("Date: BeginDay = $BeginDay<br>\n"); }
313  if ($this->DebugLevel > 1) { print("Date: EndYear = $EndYear<br>\n"); }
314  if ($this->DebugLevel > 1) { print("Date: EndMonth = $EndMonth<br>\n"); }
315  if ($this->DebugLevel > 1) { print("Date: EndDay = $EndDay<br>\n"); }
316  if ($this->DebugLevel > 1) { print("Date: Precision = ".$this->FormattedPrecision()."<br>\n"); }
317  $this->BeginYear = isset($BeginYear) ? $BeginYear : NULL ;
318  $this->BeginMonth = isset($BeginMonth) ? $BeginMonth : NULL ;
319  $this->BeginDay = isset($BeginDay) ? $BeginDay : NULL ;
320  $this->EndYear = isset($EndYear) ? $EndYear : NULL ;
321  $this->EndMonth = isset($EndMonth) ? $EndMonth : NULL ;
322  $this->EndDay = isset($EndDay) ? $EndDay : NULL ;
323  }
324 
325  # return value suitable for display
326  function Formatted()
327  {
328  # if begin year available
329  $DateString = "";
330  if ($this->Precision & DATEPRE_BEGINYEAR)
331  {
332  # start with begin year
333  $DateString = $this->BeginYear;
334 
335  # if begin month available
336  if ($this->Precision & DATEPRE_BEGINMONTH)
337  {
338  # add begin month
339  $DateString .= "-".$this->BeginMonth;
340 
341  # if begin day available
342  if ($this->Precision & DATEPRE_BEGINDAY)
343  {
344  # add begin day
345  $DateString .= "-".$this->BeginDay;
346  }
347  }
348 
349  # if end year available
350  if ($this->Precision & DATEPRE_ENDYEAR)
351  {
352  # if separate dates
353  if ($this->Precision & DATEPRE_SEPARATE)
354  {
355  # separate dates with comma
356  $DateString .= ", ";
357  }
358  else
359  {
360  # separate dates with dash
361  $DateString .= " - ";
362  }
363 
364  # add end year
365  $DateString .= $this->EndYear;
366 
367  # if end month available
368  if ($this->Precision & DATEPRE_ENDMONTH)
369  {
370  # add end month
371  $DateString .= "-".$this->EndMonth;
372 
373  # if end day available
374  if ($this->Precision & DATEPRE_ENDDAY)
375  {
376  # add end day
377  $DateString .= "-".$this->EndDay;
378  }
379  }
380  }
381  else
382  {
383  # if date is open-ended
384  if ($this->Precision & DATEPRE_CONTINUOUS)
385  {
386  # add dash to indicate open-ended
387  $DateString .= "-";
388  }
389  }
390 
391  # if copyright flag is set
392  if ($this->Precision & DATEPRE_COPYRIGHT)
393  {
394  # add on copyright indicator
395  $DateString = "c".$DateString;
396  }
397 
398  # if flag is set indicating date was inferred
399  if ($this->Precision & DATEPRE_INFERRED)
400  {
401  # add on inferred indicators
402  $DateString = "[".$DateString."]";
403  }
404  }
405 
406  # return formatted date string to caller
407  return $DateString;
408  }
409 
410  # return date in format specified like PHP date() format parameter
411  function PFormatted($Format, $ReturnEndDate = FALSE)
412  {
413  if ($ReturnEndDate)
414  {
415  $Month = ($this->Precision & DATEPRE_ENDMONTH) ? $this->EndMonth : 1;
416  $Day = ($this->Precision & DATEPRE_ENDDAY) ? $this->EndDay : 1;
417  $Year = ($this->Precision & DATEPRE_ENDYEAR) ? $this->EndYear : 1;
418  }
419  else
420  {
421  $Month = ($this->Precision & DATEPRE_BEGINMONTH) ? $this->BeginMonth : 1;
422  $Day = ($this->Precision & DATEPRE_BEGINDAY) ? $this->BeginDay : 1;
423  $Year = ($this->Precision & DATEPRE_BEGINYEAR) ? $this->BeginYear : 1;
424  }
425  return date($Format, mktime(0, 0, 0, $Month, $Day, $Year));
426  }
427 
428  # get begin date/time (or end if requested) formatted for SQL DATETIME field
429  function FormattedForSql($ReturnEndDate = FALSE)
430  {
431  return $this->PFormatted("Y-m-d H:i:s", $ReturnEndDate);
432  }
433 
434  # return begin time in ISO 8601 format
435  function FormattedISO8601()
436  {
437  # start out assuming date will be empty
438  $DateString = "";
439 
440  # if begin year available
441  if ($this->Precision & DATEPRE_BEGINYEAR)
442  {
443  # start with begin year
444  $DateString = sprintf("%04d", $this->BeginYear);
445 
446  # if begin month available
447  if ($this->Precision & DATEPRE_BEGINMONTH)
448  {
449  # add begin month
450  $DateString .= sprintf("-%02d", $this->BeginMonth);
451 
452  # if begin day available
453  if ($this->Precision & DATEPRE_BEGINDAY)
454  {
455  # add begin day
456  $DateString .= sprintf("-%02d", $this->BeginDay);
457  }
458  }
459  }
460 
461  # return ISO 8601 formatted date string to caller
462  return $DateString;
463  }
464 
465  # return values in UTC instead of local time (NOT IMPLEMENTED)
466  function UseUTC()
467  {
468  # if not currently in UTC
469  if ($this->InUTC != TRUE)
470  {
471  # adjust date to UTC
472  # ???
473 
474  # set flag to indicate we are in UTC
475  $this->InUTC = TRUE;
476  }
477  }
478 
479  # return values in local time instead of UTC (NOT IMPLEMENTED)
480  function UseLocalTime()
481  {
482  # if currently in UTC
483  if ($this->InUTC)
484  {
485  # adjust date to local time
486  # ???
487 
488  # set flag to indicate we are in local time
489  $this->InUTC = FALSE;
490  }
491  }
492 
493  # return normalized values (suitable for storing via SQL)
494  function BeginDate()
495  {
496  # build date string based on current precision
497  if ($this->Precision & DATEPRE_BEGINYEAR)
498  {
499  if ($this->Precision & DATEPRE_BEGINMONTH)
500  {
501  if ($this->Precision & DATEPRE_BEGINMONTH)
502  {
503  $DateFormat = "%04d-%02d-%02d";
504  }
505  else
506  {
507  $DateFormat = "%04d-%02d-01";
508  }
509  }
510  else
511  {
512  $DateFormat = "%04d-01-01";
513  }
514 
515  $DateString = sprintf($DateFormat,
516  $this->BeginYear, $this->BeginMonth, $this->BeginDay);
517  }
518  else
519  {
520  $DateString = NULL;
521  }
522 
523  # return date string to caller
524  return $DateString;
525  }
526  function EndDate()
527  {
528  # build date string based on current precision
529  if ($this->Precision & DATEPRE_ENDYEAR)
530  {
531  if ($this->Precision & DATEPRE_ENDMONTH)
532  {
533  if ($this->Precision & DATEPRE_ENDMONTH)
534  {
535  $DateFormat = "%04d-%02d-%02d";
536  }
537  else
538  {
539  $DateFormat = "%04d-%02d-00";
540  }
541  }
542  else
543  {
544  $DateFormat = "%04d-00-00";
545  }
546 
547  $DateString = sprintf($DateFormat,
548  $this->EndYear, $this->EndMonth, $this->EndDay);
549  }
550  else
551  {
552  $DateString = NULL;
553  }
554 
555  # return date string to caller
556  return $DateString;
557  }
558 
559  # get or set precision value (combination of boolean flags)
560  function Precision($NewPrecision = NULL)
561  {
562  if ($NewPrecision != NULL) { $this->Precision = $NewPrecision; }
563  return $this->Precision;
564  }
565 
566  # return text of SQL condition for records that match date
567  function SqlCondition($FieldName, $EndFieldName = NULL, $Operator = "=")
568  {
569  # if no date value is set
570  if ($this->Precision < 1)
571  {
572  # if operator is equals
573  if ($Operator == "=")
574  {
575  # construct conditional that will find null dates
576  $Condition = "(".$FieldName." IS NULL OR ".$FieldName." < '0000-01-01 00:00:01')";
577  }
578  else
579  {
580  # construct conditional that will find non-null dates
581  $Condition = "(".$FieldName." > '0000-01-01 00:00:00')";
582  }
583  }
584  else
585  {
586  # use begin field name as end if no end field specified
587  if ($EndFieldName == NULL) { $EndFieldName = $FieldName; }
588 
589  # determine begin and end of range
591  if ($this->Precision & DATEPRE_BEGINMONTH)
592  {
594  if ($this->Precision & DATEPRE_BEGINDAY)
595  {
596  $BeginDay = $this->BeginDay - 1;
597  }
598  else
599  {
600  $BeginDay = 0;
601  }
602  }
603  else
604  {
605  $BeginMonth = 1;
606  $BeginDay = 0;
607  }
608  if ($this->Precision & DATEPRE_ENDYEAR)
609  {
611  if ($this->Precision & DATEPRE_ENDMONTH)
612  {
614  if ($this->Precision & DATEPRE_ENDDAY)
615  {
617  }
618  else
619  {
620  $EndMonth++;
621  $EndDay = 0;
622  }
623  }
624  else
625  {
626  $EndYear++;
627  $EndMonth = 1;
628  $EndDay = 0;
629  }
630  }
631  else
632  {
634  if ($this->Precision & DATEPRE_BEGINMONTH)
635  {
637  if ($this->Precision & DATEPRE_BEGINDAY)
638  {
639  $EndDay = $BeginDay + 1;
640  }
641  else
642  {
643  $EndMonth++;
644  $EndDay = 0;
645  }
646  }
647  else
648  {
649  $EndYear++;
650  $EndMonth = 1;
651  $EndDay = 0;
652  }
653  }
654  $RangeBegin = "'".date("Y-m-d H:i:s", mktime(23, 59, 59, $BeginMonth, $BeginDay, $BeginYear))."'";
655  $RangeEnd = "'".date("Y-m-d H:i:s", mktime(23, 59, 59, $EndMonth, $EndDay, $EndYear))."'";
656 
657  # construct SQL condition
658  switch ($Operator)
659  {
660  case ">":
661  $Condition = " ${FieldName} > ${RangeEnd} ";
662  break;
663 
664  case ">=":
665  $Condition = " ${FieldName} > ${RangeBegin} ";
666  break;
667 
668  case "<":
669  $Condition = " ${FieldName} <= ${RangeBegin} ";
670  break;
671 
672  case "<=":
673  $Condition = " ${FieldName} <= ${RangeEnd} ";
674  break;
675 
676  case "!=":
677  $Condition = " (${FieldName} <= ${RangeBegin}"
678  ." OR ${FieldName} > ${RangeEnd}) ";
679  break;
680 
681  case "=":
682  default:
683  $Condition = " (${FieldName} > ${RangeBegin}"
684  ." AND ${FieldName} <= ${RangeEnd}) ";
685  break;
686  }
687  }
688 
689  # return condition to caller
690  return $Condition;
691  }
692 
693  # return string containing printable version of precision flags
695  {
696  if ($Precision === NULL) { $Precision = $this->Precision; }
697  $String = "";
698  if ($Precision & DATEPRE_BEGINYEAR) { $String .= "| BEGINYEAR "; }
699  if ($Precision & DATEPRE_BEGINMONTH) { $String .= "| BEGINMONTH "; }
700  if ($Precision & DATEPRE_BEGINDAY) { $String .= "| BEGINDAY "; }
701  if ($Precision & DATEPRE_BEGINDECADE) { $String .= "| BEGINDECADE "; }
702  if ($Precision & DATEPRE_ENDYEAR) { $String .= "| ENDYEAR "; }
703  if ($Precision & DATEPRE_ENDMONTH) { $String .= "| ENDMONTH "; }
704  if ($Precision & DATEPRE_ENDDAY) { $String .= "| ENDDAY "; }
705  if ($Precision & DATEPRE_ENDDECADE) { $String .= "| ENDDECADE "; }
706  if ($Precision & DATEPRE_INFERRED) { $String .= "| INFERRED "; }
707  if ($Precision & DATEPRE_COPYRIGHT) { $String .= "| COPYRIGHT "; }
708  if ($Precision & DATEPRE_CONTINUOUS) { $String .= "| CONTINUOUS "; }
709  if ($Precision & DATEPRE_SEPARATE) { $String .= "| SEPARATE "; }
710  $String = preg_replace("/^\\|/", "", $String);
711  return $String;
712  }
713 
714 
715  # ---- PRIVATE INTERFACE -------------------------------------------------
716 
720  var $EndDay;
722  var $EndYear;
725 
726  # Return the first non-empty parameterized subexpression match
727  # Expects a match array from preg_match()
728  # Expects a number of array elements, eg. match1, match2, match3
729  # Checks each element and returns the first non-empty one
730  # If they are all empty, NULL is returned
731  private function ExtractMatchData( $Matches, $Member, $Max )
732  {
733  for( $i=1; $i<=$Max; $i++ )
734  {
735  if (isset($Matches[$Member.$i]) && strlen($Matches[$Member.$i])>0)
736  {
737  return $Matches[$Member.$i];
738  }
739  }
740  return NULL;
741  }
742 }
743 
744 # date precision flags
745 define("DATEPRE_BEGINYEAR", 1);
746 define("DATEPRE_BEGINMONTH", 2);
747 define("DATEPRE_BEGINDAY", 4);
748 define("DATEPRE_BEGINDECADE", 8);
749 define("DATEPRE_BEGINCENTURY",16);
750 define("DATEPRE_ENDYEAR", 32);
751 define("DATEPRE_ENDMONTH", 64);
752 define("DATEPRE_ENDDAY", 128);
753 define("DATEPRE_ENDDECADE", 256);
754 define("DATEPRE_ENDCENTURY", 512);
755 define("DATEPRE_INFERRED", 1024);
756 define("DATEPRE_COPYRIGHT", 2048);
757 define("DATEPRE_CONTINUOUS", 4096);
758 define("DATEPRE_SEPARATE", 8192);
759 define("DATEPRE_UNSURE", 16384);
760 
761 
762 ?>
$Precision
Definition: Axis--Date.php:723
$DebugLevel
Definition: Axis--Date.php:724
FormattedForSql($ReturnEndDate=FALSE)
Definition: Axis--Date.php:429
const DATEPRE_BEGINDAY
Definition: Axis--Date.php:747
const DATEPRE_INFERRED
Definition: Axis--Date.php:755
const DATEPRE_ENDMONTH
Definition: Axis--Date.php:751
const DATEPRE_CONTINUOUS
Definition: Axis--Date.php:757
SqlCondition($FieldName, $EndFieldName=NULL, $Operator="=")
Definition: Axis--Date.php:567
const DATEPRE_ENDYEAR
Definition: Axis--Date.php:750
const DATEPRE_ENDDAY
Definition: Axis--Date.php:752
const DATEPRE_BEGINDECADE
Definition: Axis--Date.php:748
UseUTC()
Definition: Axis--Date.php:466
UseLocalTime()
Definition: Axis--Date.php:480
const DATEPRE_BEGINYEAR
Definition: Axis--Date.php:745
$BeginMonth
Definition: Axis--Date.php:718
Precision($NewPrecision=NULL)
Definition: Axis--Date.php:560
const DATEPRE_ENDDECADE
Definition: Axis--Date.php:753
const DATEPRE_BEGINMONTH
Definition: Axis--Date.php:746
const DATEPRE_SEPARATE
Definition: Axis--Date.php:758
FormattedISO8601()
Definition: Axis--Date.php:435
PFormatted($Format, $ReturnEndDate=FALSE)
Definition: Axis--Date.php:411
Date($BeginDate, $EndDate=NULL, $Precision=NULL, $DebugLevel=0)
Definition: Axis--Date.php:23
EndDate()
Definition: Axis--Date.php:526
$BeginYear
Definition: Axis--Date.php:719
BeginDate()
Definition: Axis--Date.php:494
Formatted()
Definition: Axis--Date.php:326
const DATEPRE_COPYRIGHT
Definition: Axis--Date.php:756
FormattedPrecision($Precision=NULL)
Definition: Axis--Date.php:694