<?php

# fmt trims left zeros
function fmt( $text ){
	for( $i = 0; substr( $text, $i, 1 ) == "0"; $i++ ) ;
	return substr( $text, $i );
}

# par left fills string with leading zeros to length $l and appends "#"
function par( $str, $l ){
	for( $i = strlen($str); $i < $l; $i++ ) $str = "0".$str;
	return $str."#";
}

# fill left fills string with leading zeros to length $l
function fill( $str, $l ){
	for( $i = strlen($str); $i < $l; $i++ ) $str = "0".$str;
	return $str;
}

# mlst creates the mailinglist address for given proj_id and titlabb
function mlst( $ta ){
	global $maildom;
	return "\"Projekt $ta\" <".strtolower( $ta )."@$maildom>";
}

# date_de convert YYYY/MM/DD to DD.MM.YYYY
function date_de( $d ){
	return( substr( $d, 8, 2 ).".".substr( $d, 5, 2 ).".".substr( $d, 0, 4 ));
}

# time_de extracts HH:MM from datetime string
function time_de( $d ){
	return( substr( $d, 11, 5 ));
}

# dt_dt combines date_de and time_de
function dt_de( $d ){
	return date_de( $d ).", ".time_de( $d );
}

# st_de translates status
function st_de( $st ){
	global $_ini, $_arc, $_act, $_fin
	switch( $st ){
		case "ini": $st = $_ini; break;
		case "arc": $st = $_arc; break;
		case "act": $st = $_act; break;
		case "fin": $st = $_fin; break;
	}
	return $st;
}
?>