[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/js/ -> calendar.php (source)

   1  <?php /* $Id: calendar.php 38 2008-02-11 11:38:51Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/js/calendar.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly');
   4  }
   5  global $AppUI, $cal_df, $cf, $df, $tf, $cal_sdf;
   6  $df = $AppUI->getPref('SHDATEFORMAT');
   7  $tf = $AppUI->getPref('TIMEFORMAT');
   8  $cf = $df . ' ' . $tf;
   9  
  10  $cal_df = $cf;
  11  $cal_sdf = $df;
  12  
  13  //Javascript Long Date Format

  14  $cal_df = str_replace('p', 'a', $cal_df);
  15  $cal_df = str_replace('%I', '%hh', $cal_df);
  16  $cal_df = str_replace('%M', '%mm', $cal_df);
  17  $cal_df = str_replace('%m', '%MM', $cal_df);
  18  $cal_df = str_replace('%MMm', '%mm', $cal_df);
  19  $cal_df = str_replace('%d', '%dd', $cal_df);
  20  $cal_df = str_replace('%b', '%NNN', $cal_df);
  21  $cal_df = str_replace('%', '', $cal_df);
  22  
  23  //Javascript Small Date Format

  24  $cal_sdf = str_replace('p', 'a', $cal_sdf);
  25  $cal_sdf = str_replace('%I', '%hh', $cal_sdf);
  26  $cal_sdf = str_replace('%M', '%mm', $cal_sdf);
  27  $cal_sdf = str_replace('%m', '%MM', $cal_sdf);
  28  $cal_sdf = str_replace('%MMm', '%mm', $cal_sdf);
  29  $cal_sdf = str_replace('%d', '%dd', $cal_sdf);
  30  $cal_sdf = str_replace('%b', '%NNN', $cal_sdf);
  31  $cal_sdf = str_replace('%', '', $cal_sdf);
  32  ?>
  33  <script language="javascript">
  34  //w2P Related

  35  // ------------------------------------------------------------------

  36  // parseDate( date_string [, prefer_euro_format] )

  37  //

  38  // This function takes a date string and tries to match it to a

  39  // number of possible date formats to get the value. It will try to

  40  // match against the following international formats, in this order:

  41  // y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d

  42  // M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d

  43  // d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M

  44  // A second argument may be passed to instruct the method to search

  45  // for formats like d/M/y (european format) before M/d/y (American).

  46  // Returns a Date object or null if no patterns match.

  47  // ------------------------------------------------------------------

  48  function parseDate(val) {
  49      var preferEuro=(arguments.length==2)?arguments[1]:false;
  50      generalFormats=new Array('yyyyMMddHHmm', '<?php echo $cal_df ?>','yyyyMMdd', '<?php echo $cal_sdf ?>');
  51      monthFirst=new Array();
  52        dateFirst =new Array();
  53  //    generalFormats=new Array('yyyyMMddHHmm', 'NNN/dd/yyyy h:m a', 'NNN/dd/yyyy H:m', 'NNN/dd/yyyy hh:mm a', 'NNN/dd/yyyy HH:mm a', 'y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');

  54  //    monthFirst=new Array('M/d/y h:m','M-d-y h:m','M.d.y h:m','M/d/y hh:mm','M-d-y hh:mm','M.d.y hh:mm','M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');

  55  //    dateFirst =new Array('d/M/y hh:mm','d-M-y hh:mm','d.M.y hh:mm','d/M/y h:m','d-M-y h:m','d.M.y h:m','d-MMM','d/M','d-M','d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');

  56      var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
  57      var d=null;
  58      for (var i=0, i_cmp=checkList.length; i<i_cmp; i++) {
  59          var l=window[checkList[i]];
  60          for (var j=0, j_cmp=l.length; j<j_cmp; j++) {
  61              d=getDateFromFormat(val,l[j]);
  62              if (d!=0) { return new Date(d); }
  63              }
  64          }
  65      return null;
  66  }
  67  </script>


Generated: Thu Nov 20 03:00:14 2008 Cross-referenced by PHPXref 0.7