/*
** ToolsDateSelector.php3
*
* function DateTimeSelector($FieldName="", $CurrDay="", $Format="d-m-Y H:i", $YearsAhead=1, $STYLE ="", $Prompts = "");
*
* $FieldName - input field name, optional, if missed you'll got 3 selectors $_DAY, $_MONTH, $_YEAR
* $CurrDay - current date value, optional, default current date
* $Format - date and time input format, valid modifiers "dmYHi", valid spacers ":-/ ", default "d-m-Y H:i"
* $YearsAhead - how many year ahead in year selector, optional, default 1
* $STYLE - selectors style, optional, default empty
* $Prompts - prompts, optional, default values "День", "Месяц", "Год"
*
*/
if( $SLANG=="Ru" ){
$MONTHNAMES[1] = "Январь";
$MONTHNAMES[2] = "Февраль";
$MONTHNAMES[3] = "Март";
$MONTHNAMES[4] = "Апрель";
$MONTHNAMES[5] = "Май";
$MONTHNAMES[6] = "Июнь";
$MONTHNAMES[7] = "Июль";
$MONTHNAMES[8] = "Август";
$MONTHNAMES[9] = "Сентябрь";
$MONTHNAMES[10] = "Октябрь";
$MONTHNAMES[11] = "Ноябрь";
$MONTHNAMES[12] = "Декабрь";
define('CALENDAR_LABEL_YEAR', "год");
define('CALENDAR_LABEL_MONTH', "месяц");
define('CALENDAR_LABEL_DAY', "день");
define('CALENDAR_LABEL_HOUR', "час");
define('CALENDAR_LABEL_MINUTE', "минута");
}else{
$MONTHNAMES[1] = "Jan";
$MONTHNAMES[2] = "Feb";
$MONTHNAMES[3] = "Mar";
$MONTHNAMES[4] = "Apr";
$MONTHNAMES[5] = "May";
$MONTHNAMES[6] = "Jun";
$MONTHNAMES[7] = "Jul";
$MONTHNAMES[8] = "Aug";
$MONTHNAMES[9] = "Sep";
$MONTHNAMES[10] = "Oct";
$MONTHNAMES[11] = "Now";
$MONTHNAMES[12] = "Dec";
define('CALENDAR_LABEL_YEAR', "year");
define('CALENDAR_LABEL_MONTH', "month");
define('CALENDAR_LABEL_DAY', "day");
define('CALENDAR_LABEL_HOUR', "hour");
define('CALENDAR_LABEL_MINUTE', "minute");
}
function DateTimeSelector($FieldName="", $CurrDay="", $Format="d-m-Y H:i", $YearsAhead=1, $STYLE ="", $Prompts = ""){
global $MONTHNAMES;
$CurrDay = trim($CurrDay);
if( ($CurrDay == "") || ($CurrDay == "0000-00-0000:00:00") || ($CurrDay == "0000-00-00 00:00:00") ){
$CurrDay = date("Y-m-d H:i");
}
$CDA1 = split(" ", $CurrDay);
$CDA = split("-", $CDA1[0]);
$CTI = split(":", $CDA1[1]);
if( !is_array($Prompts) ){
$Prompts[4] = CALENDAR_LABEL_MINUTE;
$Prompts[3] = CALENDAR_LABEL_HOUR;
$Prompts[2] = CALENDAR_LABEL_DAY;
$Prompts[1] = CALENDAR_LABEL_MONTH;
$Prompts[0] = CALENDAR_LABEL_YEAR;
}
$Out = "";
$Format = preg_split('//', $Format, -1, PREG_SPLIT_NO_EMPTY);
foreach( $Format as $key=>$val ){
switch( $val ){
case "d":
$Out .= "";
break;
case "m":
$Out .= "";
break;
case "Y":
$Out .= "";
break;
case "H":
$Out .= "";
break;
case "i":
$Out .= "";
break;
case " ":
$Out .= " ";
break;
case "-":
case "/":
case ":":
$Out .= $val;
break;
default:
$Out .= "DateTimeSelector: invalid modifier `$val'.";
break;
}
}
return $Out;
} // DateTimeSelector
function TimeSelector($FieldName="", $CurrDay="", $STYLE ="", $Prompts = ""){
$CurrDay = trim($CurrDay);
if( ($CurrDay == "") || ($CurrDay == "0000-00-0000:00:00") || ($CurrDay == "0000-00-00 00:00:00") ){
$CurrDay = date("Y-m-d H:i");
}
$CDA1 = split(" ", $CurrDay);
$CDA = split("-", $CDA1[0]);
$CTI = split(":", $CDA1[1]);
if( !is_array($Prompts) ){
$Prompts[4] = CALENDAR_LABEL_MINUTE;
$Prompts[3] = CALENDAR_LABEL_HOUR;
$Prompts[2] = CALENDAR_LABEL_DAY;
$Prompts[1] = CALENDAR_LABEL_MONTH;
$Prompts[0] = CALENDAR_LABEL_YEAR;
}
$Out = " ";
$Out .= " : ";
$Out .= " ";
return $Out;
} // TimeSelector
?>