quarta-feira, 16 de agosto de 2017

Função getDescricaoEstado a partir de uma sigla de estado


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function getDescricaoEstado(uf:string) : string;
begin
 if uf = 'PR' then
    result := 'Parana'
 else if uf = 'SC' then
    result := 'Santa Catarina'
 else if uf = 'RS' then
    result := 'Rio Grande do Sul'
 else if uf = 'SP' then
    result := 'São Paulo'
 else if uf = 'RJ' then
    result := 'Rio de Janeiro'
 else if uf = 'AC' then
    result := 'Acre'
 else if uf = 'RO' then
    result := 'Rondonia'
 else if uf = 'MS' then
    result := 'Mato Grosso do Sul'
 else if uf = 'AL' then
    result := 'Alagoas'
 else if uf = 'AM' then
    result := 'Amazonas'
 else if uf = 'AP' then
    result := 'Amapa'
 else if uf = 'CE' then
    result := 'Ceara'
 else if uf = 'BA' then
    result := 'Bahia'
 else if uf = 'DF' then
    result := 'Distrito Federal'
 else if uf = 'ES' then
    result := 'Espirito Santo'
 else if uf = 'GO' then
    result := 'Goiais'
 else if uf = 'MA' then
    result := 'Maranhao'
 else if uf = 'MT' then
    result := 'Mato Grosso'
 else if uf = 'MG' then
    result := 'Minas Gerais'
 else if uf = 'PA' then
    result := 'Para'
 else if uf = 'PB' then
    result := 'Paraiba'
 else if uf = 'PE' then
    result := 'Pernambuco'
 else if uf = 'PI' then
    result := 'Piaui'
 else if uf = 'RN' then
    result := 'Rio Grande do Norte'
 else if uf = 'RR' then
    result := 'Roraima'
 else if uf = 'SE' then
    result := 'Sergipe'
else if uf = 'TO' then
    result := 'Tocantins'
else
     result := uf;
end;

Abrir link URL no internet explorer


procedure OpenInternetExplorer( sURL : string );
const
  csOLEObjName = 'InternetExplorer.Application';
var
  IE        : Variant;
  WinHanlde : HWnd;
begin
  if( VarIsEmpty( IE ) )then
  begin
    IE := CreateOleObject( csOLEObjName );
    IE.Visible := true;
    IE.Navigate( sURL );
  end else
  begin
    WinHanlde := FindWIndow( 'IEFrame', nil );
    if( 0 <> WinHanlde )then
    begin
      IE.Navigate( sURL );
      SetForegroundWindow( WinHanlde );
    end else
    begin
      // handle error ...
    end;
  end;
end;

quarta-feira, 5 de março de 2014

Horário de Verão - ACBR

1:  /*A unit é pcnAuxiliar*/  
2:    
3:  function GetUTC(UF: string; const dataHora: TDateTime): string;  
4:  const  
5:   UTC4 = '.AC.AM.RR.RO.MT.MS.';  
6:   UTC3 = '.AP.PA.MA.PI.TO.GO.CE.RN.PB.PE.AL.SE.BA.MG.ES.RJ.SP.PR.SC.RS.DF.';  
7:  var  
8:   HorarioDeVerao: Boolean;  
9:  begin  
10:   if (UF = '90') or (UF = '91') or (UF = '') then  
11:     UF := 'DF';   
12:    
13:   HorarioDeVerao := IsHorarioDeVerao(UF, dataHora);  
14:    
15:   if AnsiPos('.' + UF + '.', UTC4) > 0 then  
16:   begin  
17:    Result := '-04:00';  
18:    if HorarioDeVerao then  
19:     Result := '-03:00';  
20:   end  
21:   else  
22:   if AnsiPos('.' + UF + '.', UTC3) > 0 then  
23:   begin  
24:    Result := '-03:00';  
25:    if IsHorarioDeVerao(UF, dataHora) then  
26:     Result := '-02:00';  
27:   end;  
28:  end;  
29:    
30:  function IsHorarioDeVerao(const UF: string; const dataHora: TDateTime): Boolean;  
31:  const  
32:   UFHV = '.MT.MS.GO.MG.ES.RJ.SP.PR.SC.RS.DF.';  
33:  var  
34:   dia: word;  
35:   mes: word;  
36:   ano: word;  
37:   anoInicio: integer;  
38:   anoFim: integer;  
39:  begin  
40:   DecodeDate(dataHora, ano, mes, dia);  
41:    
42:   { Mês de inicio do horário de verão: Outubro;  
43:    Mês de fim do horário de verão: Fevereiro;  
44:    
45:    * Se a data verificada for de um mês menor que outubro: Ex: 10/08/2010 (Agosto)  
46:      O inicio do horário de verão será OUTUBRO do ano anterior (10/2009);  
47:      O fim do horário de verão será FEVEREIRO do mesmo ano (02/2010);  
48:    
49:    * Se a data verificada for de um mês maior ou igual outubro: Ex: 10/11/2010 (Novembro)  
50:      O inicio do horário de verão será OUTUBRO do mesmo ano (10/2010);  
51:      O fim do horário de verão será FEVEREIRO do ano seguinte (02/2011);   }  
52:    
53:   anoInicio := ano;  
54:   anoFim := ano;  
55:   if mes < 10 then  
56:    anoInicio := ano - 1  
57:   else  
58:    anoFim := ano + 1;  
59:    
60:   Result := False;  
61:   if (GetInicioDoHorarioDeVerao(anoInicio) <= dataHora) and  
62:     (GetFimDoHorarioDeVerao(anoFim) >= dataHora) and  
63:     (AnsiPos(UF, UFHV) > 0) then  
64:    Result := True;  
65:     
66:  end;  
67:    
68:  function GetInicioDoHorarioDeVerao(const ano: Integer): TDateTime;  
69:  begin  
70:   {O inicio do horário de verão é no terceiro domingo do mes de outubro}  
71:   Result := GetTerceiroDomingoDoMes(ano, 10);  
72:  end;  
73:    
74:  function GetTerceiroDomingoDoMes(const ano, mes: Integer): TDateTime;  
75:  var  
76:   i: integer;  
77:  begin  
78:   {O laço vai até 7 pois até o dia 7 tem que ter passado pelo menos um domingo.  
79:    Achado o primeiro domingo, é somado a ele 14 dias para encontrar o terceiro domingo.}  
80:   result := 0;  
81:   for i := 1 to 7 do begin  
82:    if DayOfWeek(EncodeDate(ano, mes, i)) = 1 then  
83:     begin  
84:      result := EncodeDate(ano, mes, i + 14);  
85:      break;  
86:     end;  
87:   end;  
88:  end;  
89:    
90:  function GetFimDoHorarioDeVerao(const ano: Integer): TDateTime;  
91:  var  
92:   domingoCarnaval: TDateTime;  
93:   terceiroDomingoFevereiro: TDateTime;  
94:  begin  
95:   domingoCarnaval := getDataDoCarnaval(ano) - 2; //Carnaval é na terça - 2 = Domingo  
96:   terceiroDomingoFevereiro := getTerceiroDomingoDoMes(ano, 2);  
97:   if domingoCarnaval <> terceiroDomingoFevereiro then  
98:    result := terceiroDomingoFevereiro  
99:   else  
100:    result := IncDay(terceiroDomingoFevereiro, 7);  
101:  end;  

sábado, 22 de setembro de 2012

Using Data with the Metropolis UI Grid Template in Delphi and C++Builder



-->

sexta-feira, 30 de dezembro de 2011

Creating RadPHP XE2 Native iOS and Android Touch Optimized Applications