Location: PHPKode > projects > OpenBizMap > openbizmap/mydata/script/fld_date.txt
<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/


//Conversion
//convert to ISO YYYYMMDD

$len=strlen($show_value);
$ldot=strpos($show_value,'.');
$rdot=strrpos($show_value,'.');
$case=$len.'-'.$ldot.'-'.$rdot;

//YYYYMMDD
if($case=='8--')
  $show_value=$show_value;

//YYMMDD
if($case=='6--')
  if(substr($show_value,0,2)>50)
    $show_value='19'.$show_value;
  else
    $show_value='20'.$show_value;

//DD.MM.YY
if($case=='8-2-5')
  if(substr($show_value,6,2)>50)
    $show_value='19'.substr($show_value,6,2).substr($show_value,3,2).substr($show_value,0,2);
  else
    $show_value='20'.substr($show_value,6,2).substr($show_value,3,2).substr($show_value,0,2);

//DD.MM.YYYY
if($case=='10-2-5')
  $show_value=substr($show_value,6,4).substr($show_value,3,2).substr($show_value,0,2);

//D.MM.YYYY
if($case=='9-1-4')
  $show_value=substr($show_value,5,4).substr($show_value,2,2).'0'.substr($show_value,0,1);

//DD.M.YYYY
if($case=='9-2-4')
  $show_value=substr($show_value,5,4).'0'.substr($show_value,3,1).substr($show_value,0,2);

//D.MM.YY
if($case=='7-1-4')
  if(substr($show_value,5,2)>50)
    $show_value='19'.substr($show_value,5,2).substr($show_value,2,2).'0'.substr($show_value,0,1);
  else
    $show_value='20'.substr($show_value,5,2).substr($show_value,2,2).'0'.substr($show_value,0,1);

//D.M.YY
if($case=='6-1-3')
  if(substr($show_value,4,2)>50)
    $show_value='19'.substr($show_value,4,2).'0'.substr($show_value,2,1).'0'.substr($show_value,0,1);
  else
    $show_value='20'.substr($show_value,4,2).'0'.substr($show_value,2,1).'0'.substr($show_value,0,1);

//D.M.YY
if($case=='8-1-3')
  $show_value=substr($show_value,4,4).'0'.substr($show_value,2,1).'0'.substr($show_value,0,1);

//M.YYYY
if($case=='6-1-1')
  $show_value=substr($show_value,2,4).'0'.substr($show_value,0,1).'01';

if($case=='7-2-2')
  $show_value=substr($show_value,3,4).substr($show_value,0,2).'01';


if($show_mode!=CFG_SAVE)
{
  if($len)
    $show_value=substr($show_value,6,2).'.'.substr($show_value,4,2).'.'.substr($show_value,0,4);
  else
    $show_value='';
}




//------------------------------------------------------------------------------------------------

if($show_mode==CFG_SEARCH) //show search input
{
  myecho('From');
  echo(' <input class="fld_" style="width:80px;" name="'.$show_name.'_from" id="'.$show_name.'_from" type="text" title="'.$show_value.'" onkeydown="new AutoSuggestControl(this, \''.$variable_name.'_from\', new RemoteStateSuggestions());" value="'.$show_value.'" onclick="var cal=new CalendarPopup(); cal.showYearNavigation(); cal.showYearNavigationInput(); cal.setWeekStartDay(1); cal.select(this,\''.$show_name.'_from\',\'dd.MM.yyyy\'); return(false);" />');
  echo '<br />';
  myecho('To');
  echo(' <input class="fld_" style="width:80px;" name="'.$show_name.'_to" id="'.$show_name.'_to" type="text" title="'.$show_value.'" onkeydown="new AutoSuggestControl(this, \''.$variable_name.'_to\', new RemoteStateSuggestions());" value="'.$show_value.'" onclick="var cal=new CalendarPopup(); cal.showYearNavigation(); cal.showYearNavigationInput(); cal.setWeekStartDay(1); cal.select(this,\''.$show_name.'_to\',\'dd.MM.yyyy\'); return(false);" />');
}
elseif($show_mode==CFG_NEW) //show value as input for new value
{
  echo('<input class="fld_" style="width:80px;" name="'.$show_name.'" id="'.$show_name.'" type="text" value="');
    echo($show_value);
  echo('" onclick="var cal=new CalendarPopup(); cal.showYearNavigation(); cal.showYearNavigationInput(); cal.setWeekStartDay(1); cal.select(this,\''.$show_name.'\',\'dd.MM.yyyy\'); return(false);" />');
}
elseif($show_mode==CFG_SHOW) //show value in html
{
  echo('<div class="fld_">');
    if(strlen($show_value)==8)
      echo(substr($show_value,6,2).'.'.substr($show_value,4,2).'.'.substr($show_value,0,4));
    else
      echo($show_value);
  echo('</div>');
}
elseif($show_mode==CFG_EDIT) //show value as input
{
  echo('<input class="fld_" style="width:80px;" name="'.$show_name.'" id="'.$show_name.'" type="text" value="');
    if(strlen($show_value)==8)
      echo(substr($show_value,6,2).'.'.substr($show_value,4,2).'.'.substr($show_value,0,4));
    else
      echo($show_value);
  //echo('"/>');
  echo('" onclick="var cal=new CalendarPopup(); cal.showYearNavigation(); cal.showYearNavigationInput(); cal.setWeekStartDay(1); cal.select(this,\''.$show_name.'\',\'dd.MM.yyyy\'); return(false);" />');
}
elseif($show_mode==CFG_LOAD) //convert value to show format
{
}
elseif($show_mode==CFG_SAVE) //convert value to plain data
{
}

?>
Return current item: OpenBizMap