PHP Classes

File: inc.date_functions.phtml

Recommend this page to a friend!
  Classes of Ricardo Costa   DCalendar   inc.date_functions.phtml   Download  
File: inc.date_functions.phtml
Role: Auxiliary script
Content type: text/plain
Description: Date functions
Class: DCalendar
Show a calendar with options of events color
Author: By
Last change: - Added ESP and HUN names of month and days
Date: 21 years ago
Size: 2,866 bytes
 

Contents

Class file image Download
<?php
// array com os meses do ano
//ESP: $month_year = array(1 => "Janeiro", 2 => "Fevereiro", 3 => "Março", 4 => "Abril", 5 => "Maio", 6 => "Junho", 7 => "Julho", 8 => "Agosto", 9 => "Setembro", 10 => "Outubro", 11 => "Novembro", 12 => "Dezembro");
//HUN: $month_year = array(1 => "Január", 2 => "Február", 3 => "Március", 4 => "Április", 5 => "Május", 6 => "Június", 7 => "Július", 8 => "Augusztus", 9 => "Szeptember", 10 => "Október", 11 => "November", 12 => "December");
$month_year = array("","Janu&aacute;r", "Febru&aacute;r", "M&aacute;rcius", "&Aacute;prilis", "M&aacute;jus", "J&uacute;nius", "J&uacute;lius", "Augusztus", "Szeptember", "Okt&oacute;ber", "November", "December");

// array com dias da semana
//ESP: $days_week = array(0 => "Domingo", 1 => "Segunda-feira", 2 => "Ter&ccedil;a-feira", 3 => "Quarta-feira", 4 => "Quinta-feira", 5 => "Sexta-feira", 6 => "S&aacute;bado");
//HUN: $days_week = array(0 => "Vasárnap", 1 => "Hétfő", 2 => "Kedd", 3 => "Szerda", 4 => "Csütörtök", 5 => "Péntek", 6 => "Szombat");
$days_week = array("Vas&aacute;rnap", "H&eacute;tf&otilde;", "Kedd", "Szerda", "Cs&uuml;t&ouml;rt&ouml;k", "P&eacute;ntek", "Szombat");

//set the "today" string
//ESP $today = "Hoje";
//HUN $today = "Ma";
$today_str = "Ma";

// array com a data atual
$arr_day = getdate();

// definiçao de variaveis
$sec = $arr_day["minutes"];
$mi = $arr_day["seconds"];
$hour = $arr_day["hours"];
$day = $arr_day["mday"];
$day_week = $arr_day["wday"];
$day_week_ext = $days_week[$arr_day["wday"]];
$month = $arr_day["mon"];
$month_ext = $month_year[$month];
$year = $arr_day["year"];

function
mformat($zeros,$num) {
  for(
$i = 1; $i <= $zeros - strlen($num); $i++) $num = "0".$num;
  return
$num;
}


function
mno_zero($num) {
  if (
substr($num,0,1) == "0")
    return
substr($num,1,1);
  else
    return
$num;
}


function
mdia_semana($formato,$data) {
 
$d = date("w",mktime (0,0,0,mno_zero(substr($data,5,2)),mno_zero(substr($data,8,2)),substr($data,0,4)));
 
$arr_d = $GLOBALS["days_week"];
  if (
$formato == "t") return $arr_d[$d]; else return $d-1;
}


function
mdata_atual($sep) {
  return
$GLOBALS["year"].$sep.mformat(2,$GLOBALS["month"]).mformat(2,$sep.$GLOBALS["day"]);
}


function
mdata_ext($data) {
 
$arr_m = $GLOBALS["month_year"];
  return
mdia_semana("t",$data).", ".substr($data,8,2)." de ".$arr_m[date("n",mktime (0,0,0,mno_zero(substr($data,5,2)),mno_zero(substr($data,8,2)),substr($data,0,4)))]." de ".substr($data,0,4);
}


function
mdata_br($data,$sep) {
  if(
$data != "0000-00-00" && $data != "0000-00-00 00:00:00" && $data != "") return substr($data,8,2).$sep.substr($data,5,2).$sep.substr($data,0,4);
}


function
mdata_mysql($data) {
  if(
$data != "00/00/0000" && $data != "") return substr($data,6,4)."-".substr($data,3,2)."-".substr($data,0,2);
}
?>